function LayoutBuilderCompatibilityTestBase::assertFieldAttributes
Same name in other branches
- 8.9.x core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php \Drupal\Tests\layout_builder\Kernel\LayoutBuilderCompatibilityTestBase::assertFieldAttributes()
- 10 core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php \Drupal\Tests\layout_builder\Kernel\LayoutBuilderCompatibilityTestBase::assertFieldAttributes()
- 11.x core/modules/layout_builder/tests/src/Kernel/LayoutBuilderCompatibilityTestBase.php \Drupal\Tests\layout_builder\Kernel\LayoutBuilderCompatibilityTestBase::assertFieldAttributes()
Asserts that the rendered entity has the correct fields.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity to render.
array $attributes: An array of field attributes to assert.
2 calls to LayoutBuilderCompatibilityTestBase::assertFieldAttributes()
- LayoutBuilderFieldLayoutCompatibilityTest::testCompatibility in core/
modules/ layout_builder/ tests/ src/ Kernel/ LayoutBuilderFieldLayoutCompatibilityTest.php - Tests the compatibility of Layout Builder and Field Layout.
- LayoutBuilderInstallTest::testCompatibility in core/
modules/ layout_builder/ tests/ src/ Kernel/ LayoutBuilderInstallTest.php - Tests the compatibility of Layout Builder with existing entity displays.
File
-
core/
modules/ layout_builder/ tests/ src/ Kernel/ LayoutBuilderCompatibilityTestBase.php, line 115
Class
- LayoutBuilderCompatibilityTestBase
- Tests Layout Builder's compatibility with existing systems.
Namespace
Drupal\Tests\layout_builder\KernelCode
protected function assertFieldAttributes(EntityInterface $entity, array $attributes) {
$view_builder = $this->container
->get('entity_type.manager')
->getViewBuilder($entity->getEntityTypeId());
$build = $view_builder->view($entity);
$this->render($build);
$actual = array_map(function (\SimpleXMLElement $element) {
return (string) $element->attributes();
}, $this->cssSelect('.field'));
$this->assertSame($attributes, $actual);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.