function BlockLanguageTest::testLanguageBlockVisibilityLanguageDelete
Same name in other branches
- 9 core/modules/block/tests/src/Functional/BlockLanguageTest.php \Drupal\Tests\block\Functional\BlockLanguageTest::testLanguageBlockVisibilityLanguageDelete()
- 10 core/modules/block/tests/src/Functional/BlockLanguageTest.php \Drupal\Tests\block\Functional\BlockLanguageTest::testLanguageBlockVisibilityLanguageDelete()
- 11.x core/modules/block/tests/src/Functional/BlockLanguageTest.php \Drupal\Tests\block\Functional\BlockLanguageTest::testLanguageBlockVisibilityLanguageDelete()
Tests if the visibility settings are removed if the language is deleted.
File
-
core/
modules/ block/ tests/ src/ Functional/ BlockLanguageTest.php, line 87
Class
- BlockLanguageTest
- Tests if a block can be configured to be only visible on a particular language.
Namespace
Drupal\Tests\block\FunctionalCode
public function testLanguageBlockVisibilityLanguageDelete() {
// Enable a standard block and set the visibility setting for one language.
$edit = [
'visibility' => [
'language' => [
'langcodes' => [
'fr' => 'fr',
],
'context_mapping' => [
'language' => '@language.current_language_context:language_interface',
],
],
],
];
$block = $this->drupalPlaceBlock('system_powered_by_block', $edit);
// Check that we have the language in config after saving the setting.
$visibility = $block->getVisibility();
$this->assertEqual('fr', $visibility['language']['langcodes']['fr'], 'Language is set in the block configuration.');
// Delete the language.
$this->drupalPostForm('admin/config/regional/language/delete/fr', [], t('Delete'));
// Check that the language is no longer stored in the configuration after
// it is deleted.
$block = Block::load($block->id());
$visibility = $block->getVisibility();
$this->assertTrue(empty($visibility['language']['langcodes']['fr']), 'Language is no longer not set in the block configuration after deleting the block.');
// Ensure that the block visibility for language is gone from the UI.
$this->drupalGet('admin/structure/block');
$this->clickLink('Configure');
$elements = $this->xpath('//details[@id="edit-visibility-language"]');
$this->assertTrue(empty($elements));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.