ExamplesTestBase.php
1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @file
* Contains \Drupal\examples\Tests\ExamplesTestBase.
*/
namespace Drupal\examples\Tests;
use Drupal\simpletest\WebTestBase;
/**
* A standardized base class for Examples tests.
*
* Use this base class if the Examples module being tested requires menus, local
* tasks, and actions.
*/
abstract class ExamplesTestBase extends WebTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
// Install Drupal.
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']);
}
}