blob: b769047ee35d7b8eadfd27239f1d6aa98123525e (
plain) (
blame)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<?php
declare(strict_types=1);
namespace Drupal\Tests\toolbar\Functional;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the implementation of hook_toolbar() by a module.
*
* @group toolbar
*/
class ToolbarHookToolbarTest extends BrowserTestBase {
/**
* A user with permission to access the administrative toolbar.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* {@inheritdoc}
*/
protected static $modules = ['toolbar', 'toolbar_test', 'test_page_test'];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp(): void {
parent::setUp();
// Create an administrative user and log it in.
$this->adminUser = $this->drupalCreateUser(['access toolbar']);
$this->drupalLogin($this->adminUser);
}
/**
* Tests for a tab and tray provided by a module implementing hook_toolbar().
*/
public function testHookToolbar(): void {
$this->drupalGet('test-page');
$this->assertSession()->statusCodeEquals(200);
// Assert that the toolbar is present in the HTML.
$this->assertSession()->responseContains('id="toolbar-administration"');
// Assert that the tab registered by toolbar_test is present.
$this->assertSession()->responseContains('id="toolbar-tab-testing"');
// Assert that the tab item descriptions are present.
$this->assertSession()->responseContains('title="Test tab"');
// Assert that the tray registered by toolbar_test is present.
$this->assertSession()->responseContains('id="toolbar-tray-testing"');
// Assert that tray item descriptions are present.
$this->assertSession()->responseContains('title="Test link 1 title"');
}
}
|