You are here

public function SmartlingTest::testManualContextSending in TMGMT Translator Smartling 8

Test manual context sending.

File

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

Class

SmartlingTest
Basic tests for the Smartling translator.

Namespace

Drupal\tmgmt_smartling\Tests

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