FileNameTest.php in TMGMT Translator Smartling 8.3
File
tests/src/Functional/FileNameTest.php
View source
<?php
namespace Drupal\Tests\tmgmt_smartling\Functional;
class FileNameTest extends SmartlingTestBase {
public function testTwoJobsDifferentFileName() {
$translator = $this
->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
$job = $this
->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
$fileName = $job
->getTranslatorPlugin()
->getFileName($job);
$this
->assertEqual($fileName, 'JobID1_en_fr.xml');
$newJob = $this
->requestTranslationForNode($this->testNodeId, 'de', $translator);
$newFileName = $newJob
->getTranslatorPlugin()
->getFileName($newJob);
$this
->assertEqual($newFileName, 'JobID2_en_de.xml');
$this
->assertNotEqual($job
->id(), $newJob
->id());
$this
->assertNotEqual($fileName, $newFileName);
}
public function testOriginalFilename() {
$translator = $this
->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
$job = $this
->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
$fileName = $job
->getTranslatorPlugin()
->getFileName($job);
$this
->assertEqual($fileName, 'JobID1_en_fr.xml');
}
public function testAlteredFilename() {
\Drupal::service('module_installer')
->install([
'tmgmt_smartling_test_alter_filename',
]);
$translator = $this
->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
$job = $this
->requestTranslationForNode($this->testNodeId, $this->targetLanguage, $translator);
$fileName = $job
->getTranslatorPlugin()
->getFileName($job);
$this
->assertNotEqual($fileName, 'JobID1_en_fr.xml');
$this
->assertEqual($fileName, 'TEST_job_id_1.xml');
}
}