public function LayoutSelectionFieldTest::testFieldPersistsForMultipleDisplays in Layout builder library 8
Tests that the layout_selection persists if multiple displays are using it.
File
- tests/
src/ Kernel/ LayoutSelectionFieldTest.php, line 47
Class
- LayoutSelectionFieldTest
- Tests the internal handling of the layout_selection field.
Namespace
Drupal\Tests\layout_library\KernelCode
public function testFieldPersistsForMultipleDisplays() {
/** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $full_display */
$full_display = \Drupal::service('entity_display.repository')
->getViewDisplay('node', 'test', 'full');
$this
->assertInstanceOf(LayoutEntityDisplayInterface::class, $full_display);
$full_display
->enableLayoutBuilder()
->setThirdPartySetting('layout_library', 'enable', TRUE)
->save();
$this
->assertFieldExists();
/** @var \Drupal\layout_builder\Entity\LayoutEntityDisplayInterface $teaser_display */
$teaser_display = \Drupal::service('entity_display.repository')
->getViewDisplay('node', 'test', 'teaser');
$this
->assertInstanceOf(LayoutEntityDisplayInterface::class, $teaser_display);
$teaser_display
->enableLayoutBuilder()
->setThirdPartySetting('layout_library', 'enable', TRUE)
->save();
$this
->assertFieldExists();
$teaser_display
->setThirdPartySetting('layout_library', 'enable', FALSE)
->save();
$this
->assertFieldExists();
}