LingotekSystemSiteBulkLocaleTranslationTest.php in Lingotek Translation 3.4.x
File
tests/src/Functional/LingotekSystemSiteBulkLocaleTranslationTest.php
View source
<?php
namespace Drupal\Tests\lingotek\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
class LingotekSystemSiteBulkLocaleTranslationTest extends LingotekTestBase {
public static $modules = [
'node',
'comment',
];
protected function setUp() : void {
parent::setUp();
ConfigurableLanguage::create([
'id' => 'de-at',
'label' => 'German (AT)',
])
->save();
ConfigurableLanguage::createFromLangcode('es')
->setThirdPartySetting('lingotek', 'locale', 'es_AR')
->save();
ConfigurableLanguage::createFromLangcode('es-es')
->setThirdPartySetting('lingotek', 'locale', 'es_ES')
->save();
}
public function testSystemSiteTranslationUsingLinks() {
$assert_session = $this
->assertSession();
\Drupal::state()
->set('lingotek.uploaded_content_type', 'system.site');
$this
->drupalLogin($this->rootUser);
$this
->goToConfigBulkManagementForm();
$basepath = \Drupal::request()
->getBasePath();
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefNotExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('EN', 1);
$this
->assertText(t('System information uploaded successfully'));
$this
->assertIdentical('en_US', \Drupal::state()
->get('lingotek.uploaded_locale'));
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/check_upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('EN', 1);
$this
->assertText('System information status checked successfully');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/de_AT?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('DE-AT');
$this
->assertText("Translation to de_AT requested successfully");
$this
->assertIdentical('de_AT', \Drupal::state()
->get('lingotek.added_target_locale'));
\Drupal::state()
->resetCache();
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_ES?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('ES');
$this
->assertText("Translation to es_AR requested successfully");
$this
->assertIdentical('es_AR', \Drupal::state()
->get('lingotek.added_target_locale'));
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/check_download/system.site_information_settings/system.site_information_settings/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('ES');
$this
->assertIdentical('es_AR', \Drupal::state()
->get('lingotek.checked_target_locale'));
$this
->assertText("Translation to es_AR checked successfully");
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/download/system.site_information_settings/system.site_information_settings/es_AR?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('ES');
$this
->assertText('Translation to es_AR downloaded successfully');
$this
->assertIdentical('es_AR', \Drupal::state()
->get('lingotek.downloaded_locale'));
$this
->assertLingotekWorkbenchLink('es_AR');
}
public function testSourceUpdatedAfterRequestingTranslation() {
$assert_session = $this
->assertSession();
$this
->drupalLogin($this->rootUser);
$this
->goToConfigBulkManagementForm();
$basepath = \Drupal::request()
->getBasePath();
$this
->clickLink('EN', 1);
$this
->assertText(t('System information uploaded successfully'));
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/check_upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/de_AT?destination=' . $basepath . '/admin/lingotek/config/manage');
$assert_session
->linkByHrefExists($basepath . '/admin/lingotek/config/request/system.site_information_settings/system.site_information_settings/de_AT?destination=' . $basepath . '/admin/lingotek/config/manage');
$this
->clickLink('DE-AT');
$this
->assertText("Translation to de_AT requested successfully");
$assert_session
->linkByHrefNotExists($basepath . '/admin/lingotek/config/check_upload/system.site_information_settings/system.site_information_settings?destination=' . $basepath . '/admin/lingotek/config/manage');
}
}