BaseFlowTest.php in TMGMT Translator Smartling 8.4
File
tests/src/Functional/BaseFlowTest.php
View source
<?php
namespace Drupal\Tests\tmgmt_smartling\Functional;
class BaseFlowTest extends SmartlingTestBase {
public function testUploadFileAndDownloadTranslation() {
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);
$this
->drupalGet("{$this->targetLanguage}/node/{$this->testNodeId}");
$this
->assertResponse(200);
$this
->assertText($this->testNodeTitle);
$this
->downloadAndCheckTranslatedFile($job
->id(), $fileName);
$this
->drupalGet("{$this->targetLanguage}/node/{$this->testNodeId}");
$this
->assertResponse(200);
$this
->assertNoText($this->testNodeTitle);
}
else {
$this
->fail("Smartling settings file for simpletests not found.");
}
}
public function testRequestTranslationWhenOneProviderAvailable() {
if (!empty($this->smartlingPluginProviderSettings)) {
$this
->drupalPostForm('/admin/tmgmt/translators/manage/smartling', $this->smartlingPluginProviderSettings, t('Save'));
$this
->drupalPostForm('/admin/tmgmt/translators/manage/local/delete', [], t('Delete'));
$this
->drupalPostForm('/admin/tmgmt/translators/manage/file/delete', [], t('Delete'));
$this
->drupalPostForm('/admin/tmgmt/translators/manage/test_translator/delete', [], t('Delete'));
$this
->drupalPostForm('/admin/tmgmt/sources', [
'items[1]' => 1,
'target_language' => 'de',
], t('Request translation'));
$this
->assertText('One job needs to be checked out.');
$this
->assertText('Create new job');
$this
->assertText('Add to job');
}
else {
$this
->fail("Smartling settings file for simpletests not found.");
}
}
}