LingotekContentTypeExistingBulkTranslationTest.php in Lingotek Translation 3.2.x
File
tests/src/Functional/LingotekContentTypeExistingBulkTranslationTest.php
View source
<?php
namespace Drupal\Tests\lingotek\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
class LingotekContentTypeExistingBulkTranslationTest extends LingotekTestBase {
public static $modules = [
'block',
'node',
];
protected function setUp() : void {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'article',
'name' => 'Article',
]);
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_MX')
->save();
$config = \Drupal::languageManager()
->getLanguageConfigOverride('es', 'node.type.article');
$config
->set('name', 'Translated Article')
->save();
$this
->saveLingotekConfigTranslationSettings([
'node_type' => 'automatic',
]);
}
public function testContentTypeIsUntracked() {
$assert_session = $this
->assertSession();
\Drupal::state()
->set('lingotek.uploaded_content_type', 'content_type');
$this
->drupalLogin($this->rootUser);
$this
->goToConfigBulkManagementForm('node_type');
$basepath = \Drupal::request()
->getBasePath();
$this
->assertTargetStatus('ES', 'untracked');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/upload/node_type/article?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/node_type/article/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('EN');
$this
->assertText(t('Article uploaded successfully'));
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$this
->assertTargetStatus('ES', 'untracked');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/check_upload/node_type/article?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('EN');
$this
->assertText('Article status checked successfully');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/node_type/article/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('ES');
$this
->assertText("Translation to es_MX requested successfully");
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.added_target_locale'));
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/check_download/node_type/article/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('ES');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertText("Translation to es_MX status checked successfully");
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/download/node_type/article/es_MX?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('ES');
$this
->assertText('Translation to es_MX downloaded successfully');
$this
->assertIdentical('es_MX', \Drupal::state()
->get('lingotek.downloaded_locale'));
$this
->assertLingotekWorkbenchLink('es_MX');
}
}