diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php index 773ad3a396..f03431bd69 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php @@ -17,6 +17,13 @@ class InlineBlockTest extends InlineBlockTestBase { */ protected $defaultTheme = 'classy'; + /** + * {@inheritdoc} + */ + protected static $modules = [ + 'dblog', + ]; + /** * Tests adding and editing of inline blocks. */ @@ -380,11 +387,24 @@ public function testDeletion() { $this->assertCount(1, $this->blockStorage->loadMultiple()); $default_block_id = $this->getLatestBlockEntityId(); + // Create a third node. + $this->createNode([ + 'type' => 'bundle_with_section_field', + 'title' => 'The node3 title', + 'body' => [ + [ + 'value' => 'The node3 body', + ], + ], + ]); + // Ensure the block shows up on node pages. $this->drupalGet('node/1'); $assert_session->pageTextContains('The DEFAULT block body'); $this->drupalGet('node/2'); $assert_session->pageTextContains('The DEFAULT block body'); + $this->drupalGet('node/3'); + $assert_session->pageTextContains('The DEFAULT block body'); // Enable overrides. $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); @@ -400,6 +420,10 @@ public function testDeletion() { $node_2_block_id = $this->getLatestBlockEntityId(); $this->assertCount(3, $this->blockStorage->loadMultiple()); + // Do not save the third layout, no additional block was created. + $this->drupalGet('node/3/layout'); + $this->assertCount(3, $this->blockStorage->loadMultiple()); + $this->drupalGet(static::FIELD_UI_PREFIX . '/display/default'); $this->clickLink('Manage layout'); $assert_session->addressEquals(static::FIELD_UI_PREFIX . '/display/default/layout'); @@ -416,6 +440,19 @@ public function testDeletion() { $this->assertCount(2, $this->blockStorage->loadMultiple()); $this->assertEmpty($usage->getUsage($default_block_id)); + $this->drupalGet('node/3/layout'); + $assert_session->pageTextNotContains('The DEFAULT block body'); + $log = \Drupal::database() + ->select('watchdog', 'w') + ->fields('w', ['message', 'variables']) + ->orderBy('wid', 'DESC') + ->range(0, 1) + ->execute() + ->fetch(); + + $this->assertEquals('Unable to load inline block content entity with revision ID %vid.', $log->message); + $this->assertEquals($default_block_id, unserialize($log->variables)['%vid']); + $this->drupalGet('node/1/layout'); $assert_session->pageTextContains('The DEFAULT block body'); @@ -446,11 +483,14 @@ public function testDeletion() { $default_block2_id = $this->getLatestBlockEntityId(); $this->assertCount(2, $this->blockStorage->loadMultiple()); - // Delete the other node so bundle can be deleted. + // Delete the other nodes so the bundle can be deleted. $this->assertNotEmpty($usage->getUsage($node_2_block_id)); $this->drupalGet('node/2/delete'); $page->pressButton('Delete'); $this->assertEmpty(Node::load(2)); + $this->drupalGet('node/3/delete'); + $page->pressButton('Delete'); + $this->assertEmpty(Node::load(3)); $cron->run(); // Ensure entity block was deleted. $this->assertEmpty($this->blockStorage->load($node_2_block_id));