You are here

public function ContextTest::testOverrideContextOption in TMGMT Translator Smartling 8.4

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

Test override context css class.

We must not set "sl-override-context" class for context because it causes huge load on context service.

File

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

Class

ContextTest
Context tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

public function testOverrideContextOption() {
  if (!empty($this->smartlingPluginProviderSettings)) {
    $translator = $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
    $job = $this
      ->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
    $fileName = $job
      ->getTranslatorPlugin()
      ->getFileName($job);
    $this
      ->drupalPostForm('admin/tmgmt/job_items', [
      'action' => 'tmgmt_smartling_send_context',
      'tmgmt_job_item_bulk_form[0]' => 'WyJ1bmQiLCIxIl0=',
    ], t('Apply to selected items'), [
      'query' => [
        'state' => 'All',
        'source_language' => 'All',
        'target_language' => 'All',
      ],
    ]);
    $this
      ->drupalPostForm(NULL, [], t('Send Context to Smartling'));
    $fileName = str_replace('.', '_', $fileName);
    $file_path = \Drupal::getContainer()
      ->get('file_system')
      ->realpath(\Drupal::config('system.file')
      ->get('default_scheme') . "://tmgmt_smartling_context/{$fileName}.html");
    $content = file_get_contents($file_path);
    $this
      ->assertTrue(strpos($content, 'class="sl-override-context"') === FALSE);
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}