function LayoutBuilderTest::testContextAwareLayouts
Same name in other branches
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testContextAwareLayouts()
- 11.x core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testContextAwareLayouts()
Tests that layouts can be context-aware.
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderTest.php, line 1211
Class
- LayoutBuilderTest
- Tests the Layout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testContextAwareLayouts() {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
$account = $this->drupalCreateUser([
'configure any layout',
'administer node display',
]);
$this->drupalLogin($account);
$this->drupalGet('admin/structure/types/manage/bundle_with_section_field/display/default');
$this->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$page->clickLink('Manage layout');
$page->clickLink('Add section');
$page->clickLink('Layout Builder Test: Context Aware');
$page->pressButton('Add section');
// See \Drupal\layout_builder_test\Plugin\Layout\TestContextAwareLayout::build().
$assert_session->elementExists('css', '.user--' . $account->getAccountName());
$page->clickLink('Configure Section 1');
$page->fillField('layout_settings[label]', 'My section');
$page->pressButton('Update');
$assert_session->linkExists('Configure My section');
$page->clickLink('Add block');
$page->clickLink('Powered by Drupal');
$page->pressButton('Add block');
$page->pressButton('Save layout');
$this->drupalGet('node/1');
// See \Drupal\layout_builder_test\Plugin\Layout\TestContextAwareLayout::build().
$assert_session->elementExists('css', '.user--' . $account->getAccountName());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.