class ToolbarHookToolbarTest
Same name and namespace in other branches
- 11.x core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php \Drupal\Tests\toolbar\Functional\ToolbarHookToolbarTest
- 10 core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php \Drupal\Tests\toolbar\Functional\ToolbarHookToolbarTest
- 8.9.x core/modules/toolbar/tests/src/Functional/ToolbarHookToolbarTest.php \Drupal\Tests\toolbar\Functional\ToolbarHookToolbarTest
Tests the implementation of hook_toolbar() by a module.
@group toolbar
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\toolbar\Functional\ToolbarHookToolbarTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ToolbarHookToolbarTest
File
-
core/
modules/ toolbar/ tests/ src/ Functional/ ToolbarHookToolbarTest.php, line 12
Namespace
Drupal\Tests\toolbar\FunctionalView source
class ToolbarHookToolbarTest extends BrowserTestBase {
/**
* A user with permission to access the administrative toolbar.
*
* @var \Drupal\user\UserInterface
*/
protected $adminUser;
/**
* Modules to enable.
*
* @var array
*/
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() {
$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"');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.