public function InlineBlockTest::testInlineBlocksRevisioningIntegrity in Drupal 9
Tests entity blocks revisioning.
File
- core/
modules/ layout_builder/ tests/ src/ FunctionalJavascript/ InlineBlockTest.php, line 264
Class
- InlineBlockTest
- Tests that the inline block feature works correctly.
Namespace
Drupal\Tests\layout_builder\FunctionalJavascriptCode
public function testInlineBlocksRevisioningIntegrity() {
$this
->drupalLogin($this
->drupalCreateUser([
'access contextual links',
'configure any layout',
'administer node display',
'view all revisions',
'access content',
'create and edit custom blocks',
]));
$this
->drupalGet(static::FIELD_UI_PREFIX . '/display/default');
$this
->submitForm([
'layout[enabled]' => TRUE,
'layout[allow_custom]' => TRUE,
], 'Save');
$block_1_locator = static::INLINE_BLOCK_LOCATOR;
$block_2_locator = sprintf('%s + %s', static::INLINE_BLOCK_LOCATOR, static::INLINE_BLOCK_LOCATOR);
// Add two blocks to the page and assert the content in each.
$this
->drupalGet('node/1/layout');
$this
->addInlineBlockToLayout('Block 1', 'Block 1 original');
$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.
$this
->drupalGet('node/1/layout');
$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');
$this
->configureInlineBlock('Block 1 original', 'Block 1 updated', $block_1_locator);
$this
->getSession()
->getPage()
->uncheckField('revision');
$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.
$this
->assertNodeRevisionContent(3, [
'Block 1 original',
'Block 2 original',
]);
}