ConfigTranslationUiThemeTest.php in Drupal 8
File
core/modules/config_translation/tests/src/Functional/ConfigTranslationUiThemeTest.php
View source
<?php
namespace Drupal\Tests\config_translation\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
class ConfigTranslationUiThemeTest extends BrowserTestBase {
public static $modules = [
'config_translation',
'config_translation_test',
];
protected $defaultTheme = 'stark';
protected $langcodes = [
'fr',
'ta',
];
protected $adminUser;
protected function setUp() {
parent::setUp();
$admin_permissions = [
'administer themes',
'administer languages',
'administer site configuration',
'translate configuration',
];
$this->adminUser = $this
->drupalCreateUser($admin_permissions);
foreach ($this->langcodes as $langcode) {
ConfigurableLanguage::createFromLangcode($langcode)
->save();
}
}
public function testThemeDiscovery() {
$theme = 'config_translation_test_theme';
$this
->drupalLogin($this->adminUser);
$this
->drupalGet('admin/appearance');
$elements = $this
->xpath('//a[normalize-space()=:label and contains(@href, :theme)]', [
':label' => 'Install and set as default',
':theme' => $theme,
]);
$this
->drupalGet($GLOBALS['base_root'] . $elements[0]
->getAttribute('href'), [
'external' => TRUE,
]);
$translation_base_url = 'admin/config/development/performance/translate';
$this
->drupalGet($translation_base_url);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertLinkByHref("{$translation_base_url}/fr/add");
}
}