You are here

public function LingotekAccountDisconnectFormTest::testAccountDisconnect in Lingotek Translation 3.8.x

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

Test that we can disconnect.

File

tests/src/Functional/Form/LingotekAccountDisconnectFormTest.php, line 17

Class

LingotekAccountDisconnectFormTest
Tests the Lingotek account disconnection form.

Namespace

Drupal\Tests\lingotek\Functional\Form

Code

public function testAccountDisconnect() {

  // We try to disconnect from an already connected account.
  $this
    ->drupalGet('admin/lingotek/settings');
  $this
    ->drupalPostForm(NULL, [], t('Disconnect'), [], 'lingoteksettings-tab-account-form');
  \Drupal::state()
    ->set('must_remain_disconnected', TRUE);

  // We need to confirm disconnection.
  $this
    ->drupalPostForm(NULL, [], t('Disconnect'));

  // We have been redirected to the account connection form.
  $this
    ->assertUrl('/admin/lingotek/setup/account');

  // We don't have an account anymore.
  $lingotek_config = \Drupal::config('lingotek.settings');
  $this
    ->assertNull($lingotek_config
    ->get('account.access_token'));
  $this
    ->assertNull($lingotek_config
    ->get('account.login_id'));
  $this
    ->assertNull($lingotek_config
    ->get('account.callback_url'));

  // We connect to Lingotek again and it should work. We should not need to
  // set the defaults, as they are already set.
  $this
    ->connectToLingotek();

  // We have an account again.
  $lingotek_config = \Drupal::config('lingotek.settings');
  $this
    ->assertNotNull($lingotek_config
    ->get('account.access_token'));
  $this
    ->assertNotNull($lingotek_config
    ->get('account.login_id'));
  $this
    ->assertNotNull($lingotek_config
    ->get('account.callback_url'));
}