class ExamplesBrowserTestBase

Same name in other branches
  1. 3.x tests/src/Functional/ExamplesBrowserTestBase.php \Drupal\Tests\examples\Functional\ExamplesBrowserTestBase
  2. 4.0.x tests/src/Functional/ExamplesBrowserTestBase.php \Drupal\Tests\examples\Functional\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

Expanded class hierarchy of ExamplesBrowserTestBase

13 files declare their use of ExamplesBrowserTestBase
ContentEntityExampleTest.php in content_entity_example/tests/src/Functional/ContentEntityExampleTest.php
CronExampleTest.php in cron_example/tests/src/Functional/CronExampleTest.php
DbtngExampleTest.php in dbtng_example/tests/src/Functional/DbtngExampleTest.php
EmailExampleTest.php in email_example/tests/src/Functional/EmailExampleTest.php
ExampleFunctionalTest.php in testing_example/tests/src/Functional/ExampleFunctionalTest.php

... See full list

File

tests/src/Functional/ExamplesBrowserTestBase.php, line 13

Namespace

Drupal\Tests\examples\Functional
View source
abstract class ExamplesBrowserTestBase extends BrowserTestBase {
    
    /**
     * Modules to install.
     *
     * @var array
     */
    public static $modules = [
        'examples',
        'block',
    ];
    
    /**
     * {@inheritdoc}
     */
    protected function setUp() {
        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 public static property Modules to install. 14
ExamplesBrowserTestBase::setUp protected function 4
ExamplesBrowserTestBase::setupExamplesMenus protected function Set up menus and tasks in their regions.