You are here

public function ContextTest::testSmartlingContextDebuggerSendContext in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/ContextTest.php \Drupal\Tests\tmgmt_smartling\Functional\ContextTest::testSmartlingContextDebuggerSendContext()

Test Smartling context debugger: send context.

File

tests/src/Functional/ContextTest.php, line 87

Class

ContextTest
Context tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

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,
    ]));
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}