You are here

public function ContextTest::testManualContextSending 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::testManualContextSending()

Test manual context sending.

File

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

Class

ContextTest
Context tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

public function testManualContextSending() {
  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'));
    $this
      ->drupalGet('admin/reports/dblog');
    $this
      ->assertRaw('We are about to switch user');
    $this
      ->assertRaw('User was successfully switched');
    $this
      ->assertRaw(t('Context upload for file @filename completed successfully.', [
      '@filename' => $fileName,
    ]));
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}