3 namespace Drupal\Tests\toolbar\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Tests the implementation of hook_toolbar() by a module.
12 class ToolbarHookToolbarTest extends BrowserTestBase {
15 * A user with permission to access the administrative toolbar.
17 * @var \Drupal\user\UserInterface
26 public static $modules = ['toolbar', 'toolbar_test', 'test_page_test'];
28 protected function setUp() {
31 // Create an administrative user and log it in.
32 $this->adminUser = $this->drupalCreateUser(['access toolbar']);
33 $this->drupalLogin($this->adminUser);
37 * Tests for a tab and tray provided by a module implementing hook_toolbar().
39 public function testHookToolbar() {
40 $this->drupalGet('test-page');
41 $this->assertResponse(200);
43 // Assert that the toolbar is present in the HTML.
44 $this->assertRaw('id="toolbar-administration"');
46 // Assert that the tab registered by toolbar_test is present.
47 $this->assertRaw('id="toolbar-tab-testing"');
49 // Assert that the tab item descriptions are present.
50 $this->assertRaw('title="Test tab"');
52 // Assert that the tray registered by toolbar_test is present.
53 $this->assertRaw('id="toolbar-tray-testing"');
55 // Assert that tray item descriptions are present.
56 $this->assertRaw('title="Test link 1 title"');