You are here

public function SmartlingTest::testSmartlingContextDebuggerSendContext in TMGMT Translator Smartling 8

Test Smartling context debugger: send context.

File

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

Class

SmartlingTest
Basic tests for the Smartling translator.

Namespace

Drupal\tmgmt_smartling\Tests

Code

public function testSmartlingContextDebuggerSendContext() {
  if (!empty($this->smartlingPluginProviderSettings)) {
    global $base_url;

    // Workaround: TmgmtSmartlingContextDebugForm::submitForm() uses global
    // config not provider config:
    // \Drupal::config('tmgmt.translator.smartling')->get('settings');
    $this
      ->drupalPostForm('admin/tmgmt/translators/manage/smartling', $this->smartlingPluginProviderSettings, t('Save'));
    $translator = $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
    $job = $this
      ->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
    $fileName = $job
      ->getTranslatorPlugin()
      ->getFileName($job);
    $this
      ->checkGeneratedFile($fileName, $this->testNodeTitle);
    $this
      ->drupalPostForm('admin/tmgmt/smartling-context-debug', [
      'do_direct_output' => FALSE,
      'filename' => $fileName,
      'url' => $base_url . '/node/' . $this->testNodeId,
    ], t('Test context'));
    $this
      ->assertNoText($this->testNodeTitle);
    $this
      ->assertNoText($this->testNodeBody);
    $this
      ->assertText('Smartling response');
    $this
      ->drupalGet('admin/reports/dblog');
    $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.");
  }
}