function ToolbarHookToolbarTest::testHookToolbar

Same name and namespace in other branches
  1. 9 core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php \Drupal\Tests\toolbar\Functional\ToolbarHookToolbarTest::testHookToolbar()
  2. 10 core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php \Drupal\Tests\toolbar\Functional\ToolbarHookToolbarTest::testHookToolbar()
  3. 11.x core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php \Drupal\Tests\toolbar\Functional\ToolbarHookToolbarTest::testHookToolbar()

Tests for a tab and tray provided by a module implementing hook_toolbar().

File

core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php, line 44

Class

ToolbarHookToolbarTest
Tests the implementation of <a href="/api/drupal/core%21modules%21toolbar%21toolbar.api.php/function/hook_toolbar/8.9.x" title="Add items to the toolbar menu." class="local">hook_toolbar</a>() by a module.

Namespace

Drupal\Tests\toolbar\Functional

Code

public function testHookToolbar() {
    $this->drupalGet('test-page');
    $this->assertSession()
        ->statusCodeEquals(200);
    // Assert that the toolbar is present in the HTML.
    $this->assertRaw('id="toolbar-administration"');
    // Assert that the tab registered by toolbar_test is present.
    $this->assertRaw('id="toolbar-tab-testing"');
    // Assert that the tab item descriptions are present.
    $this->assertRaw('title="Test tab"');
    // Assert that the tray registered by toolbar_test is present.
    $this->assertRaw('id="toolbar-tray-testing"');
    // Assert that tray item descriptions are present.
    $this->assertRaw('title="Test link 1 title"');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.