Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block / tests / src / Functional / BlockTestBase.php
1 <?php
2
3 namespace Drupal\Tests\block\Functional;
4
5 use Drupal\filter\Entity\FilterFormat;
6 use Drupal\Tests\BrowserTestBase;
7
8 /**
9  * Provides setup and helper methods for block module tests.
10  */
11 abstract class BlockTestBase extends BrowserTestBase {
12
13   /**
14    * Modules to install.
15    *
16    * @var array
17    */
18   public static $modules = ['block', 'filter', 'test_page_test', 'help', 'block_test'];
19
20   /**
21    * A list of theme regions to test.
22    *
23    * @var array
24    */
25   protected $regions;
26
27   /**
28    * A test user with administrative privileges.
29    *
30    * @var \Drupal\user\UserInterface
31    */
32   protected $adminUser;
33
34   /**
35    * {@inheritdoc}
36    */
37   protected function setUp() {
38     parent::setUp();
39
40     // Use the test page as the front page.
41     $this->config('system.site')->set('page.front', '/test-page')->save();
42
43     // Create Full HTML text format.
44     $full_html_format = FilterFormat::create([
45       'format' => 'full_html',
46       'name' => 'Full HTML',
47     ]);
48     $full_html_format->save();
49
50     // Create and log in an administrative user having access to the Full HTML
51     // text format.
52     $this->adminUser = $this->drupalCreateUser([
53       'administer blocks',
54       $full_html_format->getPermissionName(),
55       'access administration pages',
56     ]);
57     $this->drupalLogin($this->adminUser);
58
59     // Define the existing regions.
60     $this->regions = [
61       'header',
62       'sidebar_first',
63       'content',
64       'sidebar_second',
65       'footer',
66     ];
67     $block_storage = $this->container->get('entity_type.manager')->getStorage('block');
68     $blocks = $block_storage->loadByProperties(['theme' => $this->config('system.theme')->get('default')]);
69     foreach ($blocks as $block) {
70       $block->delete();
71     }
72   }
73
74 }