diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..8662aa9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/core/modules/language/src/Tests/LanguageSwitchingTest.php b/core/modules/language/src/Tests/LanguageSwitchingTest.php index c9ff8d0..828e943 100644 --- a/core/modules/language/src/Tests/LanguageSwitchingTest.php +++ b/core/modules/language/src/Tests/LanguageSwitchingTest.php @@ -283,6 +283,37 @@ function testLanguageBodyClass() { } + function testLanguageSwitcher() { + // Go to block layout. + $this->drupalGet('admin/structure/block'); + + // Check the link to add the block is there. + $language_switcher = $this->xpath('//*[@id="edit-category-system"]/div/ul/li[@class="language-blocklanguage-interface"]/a'); + $this->assertTrue($language_switcher, 'LanguageĀ  switcher is available.'); + + // Check the link has a tooltip. + $this->assertTrue($language_switcher[0]['title'], 'The tooltip is available.'); + + // Click to add the Language switcher. + $this->clickLink(t('Language switcher')); + + // Post the block form. + $edit = array('region' => 'sidebar_first',); + $this->drupalPostForm(NULL, $edit, t('Save block')); + + // Check the block has not been added. + $block = $this->xpath('//*[@id="blocks"]/tbody/tr[@class="draggable color-warning js-block-placed odd"]'); + $this->assertFalse($block, 'The block is not added.'); + + // Check the message is being rendered. + // TODO: The system can show more than one message, check it in a loop. + $warning_messages = $this->xpath('//div[@class="region region-content"]/div[@class="messages messages--status"]/ul/li'); + foreach($warning_messages as $warning) { + $warning_bool = ($warning->__toString() == 'The block Language Switcher cannot be added.')? true : false; + } + $this->assertTrue($warning_bool, 'Message to warning the user the block cannot be added.'); + } + /** * For authenticated users, the "active" class is set by JavaScript. *