function LayoutBuilderBlocksTest::testDeletedView
Same name in other branches
- 10 core/modules/layout_builder/tests/src/Functional/LayoutBuilderBlocksTest.php \Drupal\Tests\layout_builder\Functional\LayoutBuilderBlocksTest::testDeletedView()
Tests that deleting a View block used in Layout Builder works.
File
-
core/
modules/ layout_builder/ tests/ src/ Functional/ LayoutBuilderBlocksTest.php, line 143
Class
- LayoutBuilderBlocksTest
- Tests the Layout Builder UI with blocks.
Namespace
Drupal\Tests\layout_builder\FunctionalCode
public function testDeletedView() : void {
$assert_session = $this->assertSession();
$page = $this->getSession()
->getPage();
$this->drupalLogin($this->drupalCreateUser([
'configure any layout',
'administer node display',
]));
$field_ui_prefix = 'admin/structure/types/manage/bundle_with_section_field';
// Enable overrides.
$this->drupalGet("{$field_ui_prefix}/display/default");
$this->submitForm([
'layout[enabled]' => TRUE,
], 'Save');
$this->drupalGet("{$field_ui_prefix}/display/default");
$this->submitForm([
'layout[allow_custom]' => TRUE,
], 'Save');
$this->drupalGet('node/1');
$assert_session->linkExists('Layout');
$this->clickLink('Layout');
$this->clickLink('Add block');
$this->clickLink('Test Block View');
$page->pressButton('Add block');
$assert_session->pageTextContains('Test Block View');
$assert_session->elementExists('css', '.block-views-blocktest-block-view-block-1');
$page->pressButton('Save');
$assert_session->pageTextContains('Test Block View');
$assert_session->elementExists('css', '.block-views-blocktest-block-view-block-1');
View::load('test_block_view')->delete();
$this->drupalGet('node/1');
// Node can be loaded after deleting the View.
$assert_session->pageTextContains(Node::load(1)->getTitle());
$assert_session->pageTextNotContains('Test Block View');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.