LingotekWorkbenchRedirectControllerTest.php in Lingotek Translation 3.5.x
File
tests/src/Functional/Controller/LingotekWorkbenchRedirectControllerTest.php
View source
<?php
namespace Drupal\Tests\lingotek\Functional\Controller;
use Drupal\Core\Url;
use Drupal\frozenintime\FrozenTime;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\Tests\lingotek\Functional\LingotekTestBase;
class LingotekWorkbenchRedirectControllerTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
'frozenintime',
];
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('page_title_block', [
'region' => 'content',
'weight' => -5,
]);
$this
->drupalPlaceBlock('local_tasks_block', [
'region' => 'content',
'weight' => -10,
]);
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_AR')
->save();
ContentLanguageSettings::loadByEntityTypeBundle('node', 'article')
->setLanguageAlterable(TRUE)
->save();
\Drupal::service('content_translation.manager')
->setEnabled('node', 'article', TRUE);
drupal_static_reset();
\Drupal::entityTypeManager()
->clearCachedDefinitions();
$this
->applyEntityUpdates();
$this
->rebuildContainer();
$this
->saveLingotekContentTranslationSettingsForNodeTypes();
}
public function testWorkbenchLink() {
$this
->drupalGet(Url::fromRoute('lingotek_test.fake_sethost'));
$this
->drupalLogin($this->rootUser);
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool';
$edit['body[0][value]'] = 'Llamas are very cool';
$edit['langcode[0][value]'] = 'en';
$this
->saveAndPublishNodeForm($edit);
$this
->goToContentBulkManagementForm();
$this
->clickLink('EN');
$this
->assertText('The import for node Llamas are cool is complete.');
$this
->clickLink('ES');
$this
->assertText("Locale 'es_AR' was added as a translation target for node Llamas are cool.");
$this
->clickLink('ES');
$this
->assertText('The es_AR translation for node Llamas are cool is ready for download.');
$this
->assertLingotekDownloadTargetLink('es_AR');
$this
->clickLink('ES');
$this
->assertLingotekWorkbenchLink('es_AR');
$expiration = FrozenTime::MY_BIRTHDAY + 60 * 30;
$this
->clickLink('ES');
$basepath = \Drupal::request()
->getSchemeAndHttpHost();
$this
->assertUrl($basepath . '/workbench/document/dummy-document-hash-id/locale/es_AR');
}
}