You are here

public function LingotekAccountTest::testAccountCanConnect in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  2. 3.0.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  3. 3.1.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  4. 3.2.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  5. 3.3.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  6. 3.4.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  7. 3.5.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  8. 3.6.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  9. 3.7.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()
  10. 3.8.x tests/src/Functional/LingotekAccountTest.php \Drupal\Tests\lingotek\Functional\LingotekAccountTest::testAccountCanConnect()

Tests that the dashboard cannot be accessed without a valid user.

File

tests/src/Functional/LingotekAccountTest.php, line 29

Class

LingotekAccountTest
Tests the Lingotek dashboard.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testAccountCanConnect() {
  \Drupal::state()
    ->set('must_remain_disconnected', TRUE);
  $assert_session = $this
    ->assertSession();

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);

  // Try to navigate to the Dashboard page, and assert we are redirected.
  $this
    ->drupalGet('admin/lingotek/setup/account');

  // Fake the connection to an account in Lingotek.
  $this
    ->clickLink('Connect Lingotek Account');

  // Our fake backend generates a token, returns to the site, completes the
  // handshake and return some fake data.
  $this
    ->assertText('Your account settings have been saved.');

  // Then we can select the defaults for the different fields.
  $this
    ->drupalPostForm(NULL, [
    'community' => 'test_community',
  ], 'Next');
  $this
    ->assertText('The configuration options have been saved.');
  $this
    ->drupalPostForm(NULL, [
    'project' => 'test_project',
    'vault' => 'test_vault',
    'workflow' => 'test_workflow',
  ], 'Save configuration');
  $this
    ->assertText('The configuration options have been saved.');

  // We are done with the defaults, we should be redirected to the dashboard.
  $this
    ->assertText('Dashboard');
  $this
    ->assertUrl('admin/lingotek');
}