function LayoutEntityHelperTraitTest::testGetEntitySections
Same name in other branches
- 9 core/modules/layout_builder/tests/src/Kernel/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Kernel\LayoutEntityHelperTraitTest::testGetEntitySections()
- 10 core/modules/layout_builder/tests/src/Kernel/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Kernel\LayoutEntityHelperTraitTest::testGetEntitySections()
- 11.x core/modules/layout_builder/tests/src/Kernel/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Kernel\LayoutEntityHelperTraitTest::testGetEntitySections()
@covers ::getEntitySections
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ LayoutEntityHelperTraitTest.php, line 222
Class
- LayoutEntityHelperTraitTest
- @coversDefaultClass \Drupal\layout_builder\LayoutEntityHelperTrait
Namespace
Drupal\Tests\layout_builder\KernelCode
public function testGetEntitySections() {
$entity = EntityTest::create([
'name' => 'updated',
]);
$section_storage_manager = $this->prophesize(SectionStorageManagerInterface::class);
$section_storage_manager->load('')
->willReturn(NULL);
$section_storage = $this->prophesize(SectionStorageInterface::class);
$sections = [
new Section('layout_onecol'),
];
$this->assertCount(1, $sections);
$section_storage->getSections()
->willReturn($sections);
$section_storage->count()
->willReturn(1);
$section_storage_manager->findByContext(Argument::cetera())
->willReturn($section_storage->reveal());
$this->container
->set('plugin.manager.layout_builder.section_storage', $section_storage_manager->reveal());
$class = new TestLayoutEntityHelperTrait();
// Ensure that if the entity has a section storage the sections will be
// returned.
$this->assertSame($sections, $class->getEntitySections($entity));
$section_storage_manager->findByContext(Argument::cetera())
->willReturn(NULL);
$this->container
->set('plugin.manager.layout_builder.section_storage', $section_storage_manager->reveal());
// Ensure that if the entity has no section storage an empty array will be
// returned.
$this->assertSame([], $class->getEntitySections($entity));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.