BlockInvalidRegionTest.php in Zircon Profile 8
File
core/modules/block/src/Tests/BlockInvalidRegionTest.php
View source
<?php
namespace Drupal\block\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\block\Entity\Block;
class BlockInvalidRegionTest extends WebTestBase {
public static $modules = array(
'block',
'block_test',
);
protected function setUp() {
parent::setUp();
$admin_user = $this
->drupalCreateUser(array(
'administer site configuration',
'access administration pages',
'administer blocks',
));
$this
->drupalLogin($admin_user);
}
function testBlockInInvalidRegion() {
$block = $this
->drupalPlaceBlock('test_html');
$block
->setRegion('invalid_region');
$block
->save();
$warning_message = t('The block %info was assigned to the invalid region %region and has been disabled.', array(
'%info' => $block
->id(),
'%region' => 'invalid_region',
));
$this
->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches');
$this
->assertRaw($warning_message, 'Enabled block was in the invalid region and has been disabled.');
$this
->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches');
$this
->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
$block = Block::load($block
->id());
$block
->setRegion('invalid_region');
$block
->save();
$this
->drupalPostForm('admin/config/development/performance', array(), 'Clear all caches');
$this
->assertNoRaw($warning_message, 'Disabled block in the invalid region will not trigger the warning.');
}
}
Classes
Name |
Description |
BlockInvalidRegionTest |
Tests that an active block assigned to a non-existing region triggers the
warning message and is disabled. |