BlockTestBase.php in Drupal 9
File
core/modules/block/tests/src/Functional/BlockTestBase.php
View source
<?php
namespace Drupal\Tests\block\Functional;
use Drupal\filter\Entity\FilterFormat;
use Drupal\Tests\BrowserTestBase;
abstract class BlockTestBase extends BrowserTestBase {
protected static $modules = [
'block',
'filter',
'test_page_test',
'help',
'block_test',
];
protected $regions;
protected $adminUser;
protected function setUp() {
parent::setUp();
$this
->config('system.site')
->set('page.front', '/test-page')
->save();
$full_html_format = FilterFormat::create([
'format' => 'full_html',
'name' => 'Full HTML',
]);
$full_html_format
->save();
$this->adminUser = $this
->drupalCreateUser([
'administer blocks',
$full_html_format
->getPermissionName(),
'access administration pages',
]);
$this
->drupalLogin($this->adminUser);
$this->regions = [
'header',
'sidebar_first',
'content',
'sidebar_second',
'footer',
];
$block_storage = $this->container
->get('entity_type.manager')
->getStorage('block');
$blocks = $block_storage
->loadByProperties([
'theme' => $this
->config('system.theme')
->get('default'),
]);
foreach ($blocks as $block) {
$block
->delete();
}
}
}
Classes
Name |
Description |
BlockTestBase |
Provides setup and helper methods for block module tests. |