class NavigationDefaultBlockDefinitionTest
Tests the default block provider logic.
@group navigation
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \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\PhpUnitCompatibilityTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait
- class \Drupal\Tests\navigation\Functional\NavigationDefaultBlockDefinitionTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of NavigationDefaultBlockDefinitionTest
File
-
core/
modules/ navigation/ tests/ src/ Functional/ NavigationDefaultBlockDefinitionTest.php, line 15
Namespace
Drupal\Tests\navigation\FunctionalView source
class NavigationDefaultBlockDefinitionTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'test_page_test',
'block',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests the default block flow enabling Navigation module first.
*/
public function testNavigationDefaultAfterNavigation() : void {
$test_page_url = Url::fromRoute('test_page_test.test_page');
$module_installer = \Drupal::service('module_installer');
// After installing Navigation, the bar is present, but not the block.
$module_installer->install([
'navigation',
]);
$this->drupalLogin($this->drupalCreateUser([
'access navigation',
]));
$this->drupalGet($test_page_url);
$this->assertSession()
->elementExists('css', '.admin-toolbar');
$this->assertSession()
->elementNotExists('css', '.toolbar-button--icon--test-block');
// After installing Navigation Test Block, both elements are present.
$module_installer->install([
'navigation_test_block',
]);
$this->drupalGet($test_page_url);
$this->assertSession()
->elementExists('css', '.admin-toolbar');
$this->assertSession()
->elementContains('css', '.toolbar-button--icon--test-block', 'Test Navigation Block');
}
/**
* Tests the default block flow enabling the block provider module first.
*/
public function testNavigationDefaultBeforeNavigation() : void {
$test_page_url = Url::fromRoute('test_page_test.test_page');
$module_installer = \Drupal::service('module_installer');
// After installing Navigation Test Block, none of the elements are present.
$module_installer->install([
'navigation_test_block',
]);
$this->drupalGet($test_page_url);
$this->assertSession()
->elementNotExists('css', '.admin-toolbar');
$this->assertSession()
->elementNotExists('css', '.toolbar-button--icon--test-block');
// After installing Navigation, both elements are present.
$module_installer->install([
'navigation',
]);
$this->drupalLogin($this->drupalCreateUser([
'access navigation',
]));
$this->drupalGet($test_page_url);
$this->assertSession()
->elementExists('css', '.admin-toolbar');
$this->assertSession()
->elementContains('css', '.toolbar-button--icon--test-block', 'Test Navigation Block');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.