public function LayoutBuilderTest::testOverridesFormAlter in Drupal 8
Same name and namespace in other branches
- 9 core/modules/layout_builder/tests/src/Functional/LayoutBuilderTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderTest::testOverridesFormAlter()
Tests a custom alter of the overrides form.
File
- core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderTest.php, line 1083
Class
- LayoutBuilderTest
- Tests the Layout Builder UI.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testOverridesFormAlter() {
$assert_session = $this
->assertSession();
$page = $this
->getSession()
->getPage();
$this
->drupalLogin($this
->drupalCreateUser([
'configure any layout',
'administer node display',
'administer nodes',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Enable overrides.
$this
->drupalPostForm("{$field_ui_prefix}/display/default", [
'layout[enabled]' => TRUE,
], 'Save');
$this
->drupalPostForm("{$field_ui_prefix}/display/default", [
'layout[allow_custom]' => TRUE,
], 'Save');
$this
->drupalGet('node/1');
// The status checkbox should be checked by default.
$page
->clickLink('Layout');
$assert_session
->checkboxChecked('status[value]');
$page
->pressButton('Save layout');
$assert_session
->pageTextContains('The layout override has been saved.');
// Unchecking the status checkbox will unpublish the entity.
$page
->clickLink('Layout');
$page
->uncheckField('status[value]');
$page
->pressButton('Save layout');
$assert_session
->statusCodeEquals(403);
$assert_session
->pageTextContains('The layout override has been saved.');
}