You are here

public function SmartlingTest::testSilentSwitchingOn in TMGMT Translator Smartling 8

Test context uploading with turned on "Silent switching mode" feature.

File

src/Tests/SmartlingTest.php, line 398
Contains \Drupal\tmgmt_smartling\Tests\SmartlingTest.

Class

SmartlingTest
Basic tests for the Smartling translator.

Namespace

Drupal\tmgmt_smartling\Tests

Code

public function testSilentSwitchingOn() {
  if (!empty($this->smartlingPluginProviderSettings)) {

    // Set up silent user switching mode.
    $plugin_settings = $this->smartlingPluginProviderSettings;
    $plugin_settings['settings[context_silent_user_switching]'] = TRUE;
    $translator = $this
      ->setUpSmartlingProviderSettings($plugin_settings);
    $job = $this
      ->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
    $fileName = $job
      ->getTranslatorPlugin()
      ->getFileName($job);
    $this
      ->cronRun();
    $this
      ->drupalGet('admin/reports/dblog');
    $this
      ->assertRaw('We are about to switch user');
    $this
      ->assertNoRaw(t('User @name has logged out.', [
      '@name' => 'Anonymous',
    ]));
    $this
      ->assertNoRaw(t('User @name has logged in.', [
      '@name' => $this->smartlingPluginProviderSettings['settings[contextUsername]'],
    ]));
    $this
      ->assertRaw('User was successfully switched');
    $this
      ->assertRaw(t('Context upload for file @filename completed successfully.', [
      '@filename' => $fileName,
    ]));
    $this
      ->deleteTestFile($fileName);
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}