public function SmartlingTest::testPushBackController in TMGMT Translator Smartling 8
Test push back controller.
File
- src/
Tests/ SmartlingTest.php, line 429 - Contains \Drupal\tmgmt_smartling\Tests\SmartlingTest.
Class
- SmartlingTest
- Basic tests for the Smartling translator.
Namespace
Drupal\tmgmt_smartling\TestsCode
public function testPushBackController() {
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);
// Try to push back un-existing job.
$this
->drupalGet("tmgmt-smartling-callback/100500", [
'query' => [
'fileUri' => $fileName,
'locale' => 'fr-FR',
],
]);
$this
->assertResponse(404);
// Try to push back existing job without locale and fileUri parameters.
$this
->drupalGet("tmgmt-smartling-callback/{$job->id()}");
$this
->assertResponse(404);
// Try to push back existing job without locale parameter.
$this
->drupalGet("tmgmt-smartling-callback/{$job->id()}", [
'query' => [
'fileUri' => $fileName,
],
]);
$this
->assertResponse(404);
// Try to push back existing job without fileUri parameter.
$this
->drupalGet("tmgmt-smartling-callback/{$job->id()}", [
'query' => [
'locale' => 'fr-FR',
],
]);
$this
->assertResponse(404);
// 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);
$this
->deleteTestFile($fileName);
}
else {
$this
->fail("Smartling settings file for simpletests not found.");
}
}