class LayoutSectionItemListTest
Same name and namespace in other branches
- 11.x core/modules/layout_builder/tests/src/Kernel/LayoutSectionItemListTest.php \Drupal\Tests\layout_builder\Kernel\LayoutSectionItemListTest
Tests the field type for Layout Sections.
@coversDefaultClass \Drupal\layout_builder\Field\LayoutSectionItemList
@group layout_builder
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\layout_builder\Kernel\SectionListTestBase implements \Drupal\KernelTests\Core\Entity\EntityKernelTestBase
- class \Drupal\Tests\layout_builder\Kernel\LayoutSectionItemListTest implements \Drupal\Tests\layout_builder\Kernel\SectionListTestBase
- class \Drupal\Tests\layout_builder\Kernel\SectionListTestBase implements \Drupal\KernelTests\Core\Entity\EntityKernelTestBase
- class \Drupal\KernelTests\Core\Entity\EntityKernelTestBase uses \Drupal\Tests\user\Traits\UserCreationTrait implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of LayoutSectionItemListTest
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ LayoutSectionItemListTest.php, line 17
Namespace
Drupal\Tests\layout_builder\KernelView source
class LayoutSectionItemListTest extends SectionListTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'field',
'text',
];
/**
* {@inheritdoc}
*/
protected function getSectionList(array $section_data) {
$this->installEntitySchema('entity_test_base_field_display');
LayoutBuilderEntityViewDisplay::create([
'targetEntityType' => 'entity_test_base_field_display',
'bundle' => 'entity_test_base_field_display',
'mode' => 'default',
'status' => TRUE,
])->enableLayoutBuilder()
->setOverridable()
->save();
array_map(function ($row) {
return [
'section' => $row,
];
}, $section_data);
$entity = EntityTestBaseFieldDisplay::create([
'name' => 'The test entity',
OverridesSectionStorage::FIELD_NAME => $section_data,
]);
$entity->save();
return $entity->get(OverridesSectionStorage::FIELD_NAME);
}
/**
* @covers ::equals
*/
public function testEquals() {
$this->sectionList
->getSection(0)
->setLayoutSettings([
'foo' => 1,
]);
$second_section_storage = clone $this->sectionList;
$this->assertTrue($this->sectionList
->equals($second_section_storage));
$second_section_storage->getSection(0)
->setLayoutSettings([
'foo' => '1',
]);
$this->assertFalse($this->sectionList
->equals($second_section_storage));
}
/**
* @covers ::equals
*/
public function testEqualsNonSection() {
$list = $this->prophesize(FieldItemListInterface::class);
$this->assertFalse($this->sectionList
->equals($list->reveal()));
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.