protected function EntityFieldTest::doTestDataStructureInterfaces in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php \Drupal\KernelTests\Core\Entity\EntityFieldTest::doTestDataStructureInterfaces()
Executes the data structure interfaces tests for the given entity type.
Parameters
string $entity_type: The entity type to run the tests with.
1 call to EntityFieldTest::doTestDataStructureInterfaces()
- EntityFieldTest::testDataStructureInterfaces in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php - Tests working with the entity based upon the TypedData API.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityFieldTest.php, line 560
Class
- EntityFieldTest
- Tests the Entity Field API.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function doTestDataStructureInterfaces($entity_type) {
$entity = $this
->createTestEntity($entity_type);
// Test using the whole tree of typed data by navigating through the tree of
// contained properties and getting all contained strings, limited by a
// certain depth.
$strings = [];
$this
->getContainedStrings($entity
->getTypedData(), 0, $strings);
// @todo: Once the user entity has defined properties this should contain
// the user name and other user entity strings as well.
$target_strings = [
$entity->uuid->value,
'en',
$this->entityName,
// Bundle name.
$entity
->bundle(),
$this->entityFieldText,
// Field format.
NULL,
];
if ($entity instanceof RevisionLogInterface) {
// Adding empty string for revision message.
$target_strings[] = '';
}
asort($strings);
asort($target_strings);
$this
->assertEquals(array_values($target_strings), array_values($strings), new FormattableMarkup('%entity_type: All contained strings found.', [
'%entity_type' => $entity_type,
]));
}