Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / config / tests / src / Functional / ConfigEntityListMultilingualTest.php
1 <?php
2
3 namespace Drupal\Tests\config\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6 use Drupal\language\Entity\ConfigurableLanguage;
7
8 /**
9  * Tests the listing of configuration entities in a multilingual scenario.
10  *
11  * @group config
12  */
13 class ConfigEntityListMultilingualTest extends BrowserTestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['config_test', 'language', 'block'];
21
22   /**
23    * {@inheritdoc}
24    */
25   protected function setUp() {
26     parent::setUp();
27     // Delete the override config_test entity. It is not required by this test.
28     \Drupal::entityManager()->getStorage('config_test')->load('override')->delete();
29     ConfigurableLanguage::createFromLangcode('hu')->save();
30
31     $this->drupalPlaceBlock('local_actions_block');
32   }
33
34   /**
35    * Tests the listing UI with different language scenarios.
36    */
37   public function testListUI() {
38     // Log in as an administrative user to access the full menu trail.
39     $this->drupalLogin($this->drupalCreateUser(['access administration pages', 'administer site configuration']));
40
41     // Get the list page.
42     $this->drupalGet('admin/structure/config_test');
43     $this->assertLinkByHref('admin/structure/config_test/manage/dotted.default');
44
45     // Add a new entity using the action link.
46     $this->clickLink('Add test configuration');
47     $edit = [
48       'label' => 'Antilop',
49       'id' => 'antilop',
50       'langcode' => 'hu',
51     ];
52     $this->drupalPostForm(NULL, $edit, t('Save'));
53     // Ensure that operations for editing the Hungarian entity appear in English.
54     $this->assertLinkByHref('admin/structure/config_test/manage/antilop');
55
56     // Get the list page in Hungarian and assert Hungarian admin links
57     // regardless of language of config entities.
58     $this->drupalGet('hu/admin/structure/config_test');
59     $this->assertLinkByHref('hu/admin/structure/config_test/manage/dotted.default');
60     $this->assertLinkByHref('hu/admin/structure/config_test/manage/antilop');
61   }
62
63 }