You are here

public function LingotekAccountDisconnectFormTest::testAccountDisconnect in Lingotek Translation 8

Test that we can disconnect.

File

src/Tests/Form/LingotekAccountDisconnectFormTest.php, line 18

Class

LingotekAccountDisconnectFormTest
Tests the Lingotek account disconnection form.

Namespace

Drupal\lingotek\Tests\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');

  // 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'));
}