Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / config_translation / tests / src / Functional / ConfigTranslationUiThemeTest.php
1 <?php
2
3 namespace Drupal\Tests\config_translation\Functional;
4
5 use Drupal\language\Entity\ConfigurableLanguage;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Verifies theme configuration translation settings.
10  *
11  * @group config_translation
12  */
13 class ConfigTranslationUiThemeTest extends BrowserTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['config_translation', 'config_translation_test'];
21
22   /**
23    * Languages to enable.
24    *
25    * @var array
26    */
27   protected $langcodes = ['fr', 'ta'];
28
29   /**
30    * Administrator user for tests.
31    *
32    * @var \Drupal\user\UserInterface
33    */
34   protected $adminUser;
35
36   protected function setUp() {
37     parent::setUp();
38
39     $admin_permissions = [
40       'administer themes',
41       'administer languages',
42       'administer site configuration',
43       'translate configuration',
44     ];
45     // Create and log in user.
46     $this->adminUser = $this->drupalCreateUser($admin_permissions);
47
48     // Add languages.
49     foreach ($this->langcodes as $langcode) {
50       ConfigurableLanguage::createFromLangcode($langcode)->save();
51     }
52   }
53
54   /**
55    * Tests that theme provided *.config_translation.yml files are found.
56    */
57   public function testThemeDiscovery() {
58     // Install the test theme and rebuild routes.
59     $theme = 'config_translation_test_theme';
60
61     $this->drupalLogin($this->adminUser);
62
63     $this->drupalGet('admin/appearance');
64     $elements = $this->xpath('//a[normalize-space()=:label and contains(@href, :theme)]', [
65       ':label' => 'Install and set as default',
66       ':theme' => $theme,
67     ]);
68     $this->drupalGet($GLOBALS['base_root'] . $elements[0]->getAttribute('href'), ['external' => TRUE]);
69
70     $translation_base_url = 'admin/config/development/performance/translate';
71     $this->drupalGet($translation_base_url);
72     $this->assertResponse(200);
73     $this->assertLinkByHref("$translation_base_url/fr/add");
74   }
75
76 }