You are here

public function PushBackControllerTest::testPushBackExistingJobWithParameters in TMGMT Translator Smartling 8.4

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

Push back existing job with parameters.

File

tests/src/Functional/PushBackControllerTest.php, line 103

Class

PushBackControllerTest
Push back controller tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

public function testPushBackExistingJobWithParameters() {
  if (!empty($this->smartlingPluginProviderSettings)) {
    $translator = $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
    $job = $this
      ->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
    $fileName = $job
      ->getTranslatorPlugin()
      ->getFileName($job);
    $this
      ->checkGeneratedFile($fileName, $this->testNodeTitle);

    // Check fr node title before translation (should be same as en title).
    $this
      ->drupalGet("{$this->targetLanguage}/node/{$this->testNodeId}");
    $this
      ->assertResponse(200);
    $this
      ->assertText($this->testNodeTitle);

    // Try to push back existing job.
    $this
      ->drupalGet("tmgmt-smartling-callback/{$job->id()}", [
      'query' => [
        'fileUri' => $fileName,
        'locale' => 'fr-FR',
      ],
    ]);
    $this
      ->assertResponse(200);

    // Check fr node title after translation (should be same as en title).
    $this
      ->drupalGet("{$this->targetLanguage}/node/{$this->testNodeId}");
    $this
      ->assertResponse(200);
    $this
      ->assertNoText($this->testNodeTitle);
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}