LayoutBuilderFieldLayoutCompatibilityTest.php in Drupal 8
File
core/modules/layout_builder/tests/src/Kernel/LayoutBuilderFieldLayoutCompatibilityTest.php
View source
<?php
namespace Drupal\Tests\layout_builder\Kernel;
use Drupal\layout_builder\Plugin\SectionStorage\OverridesSectionStorage;
use Drupal\layout_builder\Section;
class LayoutBuilderFieldLayoutCompatibilityTest extends LayoutBuilderCompatibilityTestBase {
public static $modules = [
'field_layout',
];
protected function setUp() {
parent::setUp();
$this->display
->setLayoutId('layout_twocol')
->save();
}
public function testCompatibility() {
$expected_fields = [
'field field--name-name field--type-string field--label-hidden field__item',
'field field--name-test-field-display-configurable field--type-boolean field--label-above',
'clearfix text-formatted field field--name-test-display-configurable field--type-text field--label-above',
'clearfix text-formatted field field--name-test-display-non-configurable field--type-text field--label-above',
'clearfix text-formatted field field--name-test-display-multiple field--type-text field--label-above',
];
$this
->assertFieldAttributes($this->entity, $expected_fields);
$this
->assertNotEmpty($this
->cssSelect('.layout__region--first .field--name-test-display-configurable'));
$this
->assertNotEmpty($this
->cssSelect('.layout__region--first .field--name-test-field-display-configurable'));
$this
->assertNotEmpty($this
->cssSelect('.field--name-test-display-non-configurable'));
$this
->assertEmpty($this
->cssSelect('.layout__region .field--name-test-display-non-configurable'));
$this
->installLayoutBuilder();
$this
->assertFieldAttributes($this->entity, $expected_fields);
$this
->enableOverrides();
$field_list = $this->entity
->get(OverridesSectionStorage::FIELD_NAME);
$field_list
->appendSection(new Section('layout_onecol'));
$this->entity
->save();
$new_expected_fields = [
'field field--name-name field--type-string field--label-hidden field__item',
'clearfix text-formatted field field--name-test-display-non-configurable field--type-text field--label-above',
'clearfix text-formatted field field--name-test-display-multiple field--type-text field--label-above',
];
$this
->assertFieldAttributes($this->entity, $new_expected_fields);
$this
->assertNotEmpty($this
->cssSelect('.layout--onecol'));
$field_list
->removeAllSections();
$this->entity
->save();
$this
->assertFieldAttributes($this->entity, $expected_fields);
}
}