comparison core/modules/block/src/Tests/BlockTestBase.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 namespace Drupal\block\Tests;
4
5 @trigger_error(__NAMESPACE__ . '\BlockTestBase is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Instead, use \Drupal\Tests\block\Functional\BlockTestBase, see https://www.drupal.org/node/2901823.', E_USER_DEPRECATED);
6
7 use Drupal\simpletest\WebTestBase;
8 use Drupal\filter\Entity\FilterFormat;
9
10 /**
11 * Provides setup and helper methods for block module tests.
12 *
13 * @deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0.
14 * Use \Drupal\Tests\block\Functional\BlockTestBase.
15 *
16 * @see https://www.drupal.org/node/2901823
17 */
18 abstract class BlockTestBase extends WebTestBase {
19
20 /**
21 * Modules to install.
22 *
23 * @var array
24 */
25 public static $modules = ['block', 'filter', 'test_page_test', 'help', 'block_test'];
26
27 /**
28 * A list of theme regions to test.
29 *
30 * @var array
31 */
32 protected $regions;
33
34 /**
35 * A test user with administrative privileges.
36 *
37 * @var \Drupal\user\UserInterface
38 */
39 protected $adminUser;
40
41 protected function setUp() {
42 parent::setUp();
43
44 // Use the test page as the front page.
45 $this->config('system.site')->set('page.front', '/test-page')->save();
46
47 // Create Full HTML text format.
48 $full_html_format = FilterFormat::create([
49 'format' => 'full_html',
50 'name' => 'Full HTML',
51 ]);
52 $full_html_format->save();
53
54 // Create and log in an administrative user having access to the Full HTML
55 // text format.
56 $this->adminUser = $this->drupalCreateUser([
57 'administer blocks',
58 $full_html_format->getPermissionName(),
59 'access administration pages',
60 ]);
61 $this->drupalLogin($this->adminUser);
62
63 // Define the existing regions.
64 $this->regions = [
65 'header',
66 'sidebar_first',
67 'content',
68 'sidebar_second',
69 'footer',
70 ];
71 $block_storage = $this->container->get('entity_type.manager')->getStorage('block');
72 $blocks = $block_storage->loadByProperties(['theme' => $this->config('system.theme')->get('default')]);
73 foreach ($blocks as $block) {
74 $block->delete();
75 }
76 }
77
78 }