diff --git a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php index e3407a7ff4..90d28224ab 100644 --- a/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php +++ b/core/modules/layout_builder/tests/src/FunctionalJavascript/InlineBlockTest.php @@ -286,6 +286,8 @@ public function testInlineBlocksRevisioningIntegrity() { $this->addInlineBlockToLayout('Block 2', 'Block 2 original'); $this->assertSaveLayout(); $this->assertNodeRevisionContent(3, ['Block 1 original', 'Block 2 original']); + $this->assertBlockRevisionCountByTitle('Block 1', 1); + $this->assertBlockRevisionCountByTitle('Block 2', 1); // Update the contents of one of the blocks and assert the updated content // appears on the next revision. @@ -293,6 +295,8 @@ public function testInlineBlocksRevisioningIntegrity() { $this->configureInlineBlock('Block 2 original', 'Block 2 updated', $block_2_locator); $this->assertSaveLayout(); $this->assertNodeRevisionContent(4, ['Block 1 original', 'Block 2 updated']); + $this->assertBlockRevisionCountByTitle('Block 1', 1); + $this->assertBlockRevisionCountByTitle('Block 2', 2); // Update block 1 without creating a new revision of the parent. $this->drupalGet('node/1/layout'); @@ -301,6 +305,8 @@ public function testInlineBlocksRevisioningIntegrity() { $this->getSession()->getPage()->pressButton('Save layout'); $this->assertNotEmpty($this->assertSession()->waitForElement('css', '.messages--status')); $this->assertNodeRevisionContent(4, ['Block 1 updated', 'Block 2 updated']); + $this->assertBlockRevisionCountByTitle('Block 1', 2); + $this->assertBlockRevisionCountByTitle('Block 2', 2); // Reassert all of the parent revisions contain the correct block content // and the integrity of the revisions was preserved. @@ -323,6 +329,23 @@ protected function assertNodeRevisionContent($revision_id, array $content) { } } + /** + * Assert the number of block content revisions by the block title. + * + * @param string $block_title + * The block title. + * @param int $expected_revision_count + * The revision count. + */ + protected function assertBlockRevisionCountByTitle($block_title, $expected_revision_count) { + $actual_revision_count = $this->blockStorage->getQuery() + ->condition('info', $block_title) + ->allRevisions() + ->count() + ->execute(); + $this->assertEquals($actual_revision_count, $expected_revision_count); + } + /** * Tests that entity blocks deleted correctly. */