public function RevisionInflationTest::testRevisionInflation in TMGMT Translator Smartling 8.3
Same name and namespace in other branches
- 8.4 tests/src/Functional/RevisionInflationTest.php \Drupal\Tests\tmgmt_smartling\Functional\RevisionInflationTest::testRevisionInflation()
Test revision inflation.
File
- tests/
src/ Functional/ RevisionInflationTest.php, line 18
Class
- RevisionInflationTest
- Revision inflation tests.
Namespace
Drupal\Tests\tmgmt_smartling\FunctionalCode
public function testRevisionInflation() {
if (!empty($this->smartlingPluginProviderSettings)) {
$node_1 = Node::create([
'title' => t('Post 1 title'),
'type' => 'translatable_node',
'uid' => '0',
'sticky' => TRUE,
'body' => [
'value' => 'Post 1 body',
'format' => 'basic_html',
],
]);
$node_1
->save();
$node_2 = Node::create([
'title' => t('Post 2 title'),
'type' => 'translatable_node',
'uid' => '0',
'sticky' => TRUE,
'body' => [
'value' => 'Post 2 body',
'format' => 'basic_html',
],
]);
$node_2
->save();
$providerSettings = $this->smartlingPluginProviderSettings;
$translator = $this
->setUpSmartlingProviderSettings($providerSettings);
$job = $this
->requestTranslationForNode([
$node_1
->id(),
$node_2
->id(),
], $this->targetLanguage, $translator);
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertNoText("has been accepted as");
$this
->assertNoText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isActive());
$job
->getTranslatorPlugin()
->downloadTranslation($job);
$job = Job::load($job
->id());
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertText("The translation for Post 1 title has been accepted");
$this
->assertText("The translation for Post 2 title has been accepted");
$this
->assertNoText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
foreach ($job
->getItems() as $item) {
$this
->assertEqual($item
->isAccepted(), TRUE);
}
$job
->getTranslatorPlugin()
->downloadTranslation($job);
$job = Job::load($job
->id());
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
foreach ($job
->getItems() as $item) {
$this
->assertEqual($item
->isAccepted(), TRUE);
}
foreach ($job
->getMessages() as $message) {
$message
->delete();
}
// Delete translation from one node.
$node_1 = Node::load($node_1
->id());
$node_1
->removeTranslation($this->targetLanguage);
$node_1
->save();
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertNoText("has been accepted as");
$this
->assertNoText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
$job
->getTranslatorPlugin()
->downloadTranslation($job);
$job = Job::load($job
->id());
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertText("The translation for Post 1 title has been accepted");
$this
->assertNoText("The translation for Post 2 title has been accepted");
$this
->assertNoText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
foreach ($job
->getItems() as $item) {
$this
->assertEqual($item
->isAccepted(), TRUE);
}
$job
->getTranslatorPlugin()
->downloadTranslation($job);
$job = Job::load($job
->id());
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertNoText("The translation for Post 2 title has been accepted");
$this
->assertText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
foreach ($job
->getItems() as $item) {
$this
->assertEqual($item
->isAccepted(), TRUE);
}
foreach ($job
->getMessages() as $message) {
$message
->delete();
}
// Delete translation from all the nodes.
$node_1 = Node::load($node_1
->id());
$node_1
->removeTranslation($this->targetLanguage);
$node_1
->save();
$node_2 = Node::load($node_2
->id());
$node_2
->removeTranslation($this->targetLanguage);
$node_2
->save();
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertNoText("has been accepted as");
$this
->assertNoText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
$job
->getTranslatorPlugin()
->downloadTranslation($job);
$job = Job::load($job
->id());
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertText("The translation for Post 1 title has been accepted");
$this
->assertText("The translation for Post 2 title has been accepted");
$this
->assertNoText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
foreach ($job
->getItems() as $item) {
$this
->assertEqual($item
->isAccepted(), TRUE);
}
$job
->getTranslatorPlugin()
->downloadTranslation($job);
$job = Job::load($job
->id());
$this
->drupalGet("/admin/tmgmt/jobs/1");
$this
->assertResponse(200);
$this
->assertText("Import of downloaded file was skipped: downloaded and existing translations are equal.");
$this
->assertTrue($job
->isFinished());
foreach ($job
->getItems() as $item) {
$this
->assertEqual($item
->isAccepted(), TRUE);
}
}
else {
$this
->fail("Smartling settings file for simpletests not found.");
}
}