class LayoutBuilderToolbarTest
Same name and namespace in other branches
- 11.x core/modules/layout_builder/tests/src/FunctionalJavascript/LayoutBuilderToolbarTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderToolbarTest
Test Layout Builder integration with Toolbar.
@group layout_builder
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 implements \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\layout_builder\FunctionalJavascript\LayoutBuilderToolbarTest implements \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of LayoutBuilderToolbarTest
File
-
core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ LayoutBuilderToolbarTest.php, line 12
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptView source
class LayoutBuilderToolbarTest extends WebDriverTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'block',
'node',
'field_ui',
'layout_builder',
'node',
'toolbar',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'starterkit_theme';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->drupalPlaceBlock('local_tasks_block');
// Create a content type.
$this->createContentType([
'type' => 'bundle_with_section_field',
'name' => 'Bundle with section field',
]);
$this->createNode([
'type' => 'bundle_with_section_field',
'title' => 'The first node title',
'body' => [
[
'value' => 'The first node body',
],
],
]);
}
/**
* Tests the 'Back to site' link behaves with manage layout as admin page.
*/
public function testBackToSiteLink() {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'access administration pages',
'administer node display',
'administer node fields',
'access toolbar',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// From the manage display page, go to manage the layout.
$this->drupalGet("{$field_ui_prefix}/display/default");
$this->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$assert_session->linkExists('Manage layout');
$this->clickLink('Manage layout');
// Save the defaults.
$page->pressButton('Save layout');
$assert_session->addressEquals("{$field_ui_prefix}/display/default");
// As the Layout Builder UI is typically displayed using the frontend theme,
// it is not marked as an administrative page at the route level even though
// it performs an administrative task, therefore, we need to verify that it
// behaves as such, redirecting out of the admin section.
// Clicking "Back to site" navigates to the homepage.
$this->drupalGet("{$field_ui_prefix}/display/default/layout");
$this->clickLink('Back to site');
$assert_session->addressEquals("/user/2");
$this->drupalGet("{$field_ui_prefix}/display/default/layout/discard-changes");
$page->pressButton('Confirm');
$this->clickLink('Back to site');
$assert_session->addressEquals("/user/2");
$this->drupalGet("{$field_ui_prefix}/display/default/layout/disable");
$page->pressButton('Confirm');
$this->clickLink('Back to site');
$assert_session->addressEquals("/user/2");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.