class ExamplesBrowserTestBase
A standardized base class for Examples tests.
Use this base class if the Examples module being tested requires menus, local tasks, and actions.
Hierarchy
- class \Drupal\Tests\examples\Functional\ExamplesBrowserTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ExamplesBrowserTestBase
17 files declare their use of ExamplesBrowserTestBase
- ActionExampleTest.php in modules/
action_example/ tests/ src/ Functional/ ActionExampleTest.php - ConfigExampleTest.php in modules/
config_simple_example/ tests/ src/ Functional/ ConfigExampleTest.php - ContentEntityExampleTest.php in modules/
content_entity_example/ tests/ src/ Functional/ ContentEntityExampleTest.php - CronExampleTest.php in modules/
cron_example/ tests/ src/ Functional/ CronExampleTest.php - DbtngExampleTest.php in modules/
dbtng_example/ tests/ src/ Functional/ DbtngExampleTest.php
File
-
tests/
src/ Functional/ ExamplesBrowserTestBase.php, line 13
Namespace
Drupal\Tests\examples\FunctionalView source
abstract class ExamplesBrowserTestBase extends BrowserTestBase {
/**
* Modules to install.
*
* @var array
*/
protected static $modules = [
'examples',
'block',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
// Add the system menu blocks to appropriate regions.
$this->setupExamplesMenus();
}
/**
* Set up menus and tasks in their regions.
*
* Since menus and tasks are now blocks, we're required to explicitly set them
* to regions. This method standardizes the way we do that for Examples.
*
* Note that subclasses must explicitly declare that the block module is a
* dependency.
*/
protected function setupExamplesMenus() {
$this->drupalPlaceBlock('system_menu_block:tools', [
'region' => 'primary_menu',
]);
$this->drupalPlaceBlock('local_tasks_block', [
'region' => 'secondary_menu',
]);
$this->drupalPlaceBlock('local_actions_block', [
'region' => 'content',
]);
$this->drupalPlaceBlock('page_title_block', [
'region' => 'content',
]);
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overrides |
|---|---|---|---|---|
| ExamplesBrowserTestBase::$modules | protected static | property | Modules to install. | 18 |
| ExamplesBrowserTestBase::setUp | protected | function | 5 | |
| ExamplesBrowserTestBase::setupExamplesMenus | protected | function | Set up menus and tasks in their regions. |