class NavigationDefaultBlockDefinitionTest
Same name in this branch
- main core/modules/navigation/tests/src/Functional/NavigationDefaultBlockDefinitionTest.php \Drupal\Tests\navigation\Functional\NavigationDefaultBlockDefinitionTest
Same name and namespace in other branches
- 11.x core/modules/navigation/tests/src/Functional/NavigationDefaultBlockDefinitionTest.php \Drupal\Tests\navigation\Functional\NavigationDefaultBlockDefinitionTest
Tests the default block provider logic.
Attributes
#[Group('navigation')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\Tests\navigation\Kernel\NavigationDefaultBlockDefinitionTest uses \Drupal\Tests\user\Traits\UserCreationTrait extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of NavigationDefaultBlockDefinitionTest
File
-
core/
modules/ navigation/ tests/ src/ Kernel/ NavigationDefaultBlockDefinitionTest.php, line 16
Namespace
Drupal\Tests\navigation\KernelView source
class NavigationDefaultBlockDefinitionTest extends KernelTestBase {
use UserCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'test_page_test',
'block',
'user',
'system',
'layout_discovery',
'layout_builder',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('user');
}
/**
* 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->installConfig([
'navigation',
]);
$this->setCurrentUser($this->createUser([
'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',
]);
// Refresh the mink session so we don't have a stale container.
// @todo remove after https://www.drupal.org/project/drupal/issues/3609730
$this->initMink();
$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',
]);
// Refresh the mink session so we don't have a stale container.
$this->initMink();
$this->setCurrentUser($this->createUser([
'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.