comparison core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.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\Tests\toolbar\Functional;
4
5 use Drupal\Tests\BrowserTestBase;
6
7 /**
8 * Tests the implementation of hook_toolbar() by a module.
9 *
10 * @group toolbar
11 */
12 class ToolbarHookToolbarTest extends BrowserTestBase {
13
14 /**
15 * A user with permission to access the administrative toolbar.
16 *
17 * @var \Drupal\user\UserInterface
18 */
19 protected $adminUser;
20
21 /**
22 * Modules to enable.
23 *
24 * @var array
25 */
26 public static $modules = ['toolbar', 'toolbar_test', 'test_page_test'];
27
28 protected function setUp() {
29 parent::setUp();
30
31 // Create an administrative user and log it in.
32 $this->adminUser = $this->drupalCreateUser(['access toolbar']);
33 $this->drupalLogin($this->adminUser);
34 }
35
36 /**
37 * Tests for a tab and tray provided by a module implementing hook_toolbar().
38 */
39 public function testHookToolbar() {
40 $this->drupalGet('test-page');
41 $this->assertResponse(200);
42
43 // Assert that the toolbar is present in the HTML.
44 $this->assertRaw('id="toolbar-administration"');
45
46 // Assert that the tab registered by toolbar_test is present.
47 $this->assertRaw('id="toolbar-tab-testing"');
48
49 // Assert that the tab item descriptions are present.
50 $this->assertRaw('title="Test tab"');
51
52 // Assert that the tray registered by toolbar_test is present.
53 $this->assertRaw('id="toolbar-tray-testing"');
54
55 // Assert that tray item descriptions are present.
56 $this->assertRaw('title="Test link 1 title"');
57 }
58
59 }