protected function EntityShareClientFunctionalTestBase::checkCreatedEntities in Entity Share 8.2
Same name and namespace in other branches
- 8.3 modules/entity_share_client/tests/src/Functional/EntityShareClientFunctionalTestBase.php \Drupal\Tests\entity_share_client\Functional\EntityShareClientFunctionalTestBase::checkCreatedEntities()
Helper function that test that the entities had been recreated.
20 calls to EntityShareClientFunctionalTestBase::checkCreatedEntities()
- BasicFieldsTest::testBasicPull in modules/
entity_share_client/ tests/ src/ Functional/ BasicFieldsTest.php - Test basic pull feature.
- BcTimestampNormalizerUnixTest::testBasicPull in modules/
entity_share_client/ tests/ src/ Functional/ BcTimestampNormalizerUnixTest.php - Test basic pull feature.
- BlockFieldTest::testBasicPull in modules/
entity_share_client/ tests/ src/ Functional/ BlockFieldTest.php - Test basic pull feature.
- ChangedRemovedTest::testBasicPull in modules/
entity_share_client/ tests/ src/ Functional/ ChangedRemovedTest.php - Test basic pull feature.
- CliTest::testPull in modules/
entity_share_client/ tests/ src/ Functional/ CliTest.php - Test pull command.
File
- modules/
entity_share_client/ tests/ src/ Functional/ EntityShareClientFunctionalTestBase.php, line 467
Class
- EntityShareClientFunctionalTestBase
- Base class for Entity share server functional tests.
Namespace
Drupal\Tests\entity_share_client\FunctionalCode
protected function checkCreatedEntities() {
$entities_data = $this
->getEntitiesData();
foreach ($entities_data as $entity_type_id => $data_per_languages) {
$entity_storage = $this->entityTypeManager
->getStorage($entity_type_id);
foreach ($data_per_languages as $language_id => $entity_data) {
foreach ($entity_data as $entity_uuid => $entity_data_per_field) {
/** @var \Drupal\Core\Entity\ContentEntityInterface[] $recreated_entities */
$recreated_entities = $entity_storage
->loadByProperties([
'uuid' => $entity_uuid,
]);
// Check that the entity has been recreated.
$this
->assertTrue(!empty($recreated_entities), 'The ' . $entity_type_id . ' with UUID ' . $entity_uuid . ' has been recreated.');
// Check the values.
if (!empty($recreated_entities)) {
$recreated_entity = array_shift($recreated_entities);
$entity_translation = $recreated_entity
->getTranslation($language_id);
foreach ($entity_data_per_field as $field_machine_name => $data) {
// Some data are dynamic.
if (isset($data['value_callback'])) {
$data['value'] = call_user_func($data['value_callback']);
}
// When additional keys in field data are created by Drupal. We
// need to filter this structure.
if ($data['checker_callback'] == 'getFilteredStructureValues') {
// Assume that also for single value fields, the data will be
// set using an array of values.
$structure = array_keys($data['value'][0]);
$this
->assertEquals($data['value'], $this
->getFilteredStructureValues($entity_translation, $field_machine_name, $structure), 'The data of the field ' . $field_machine_name . ' has been recreated.');
}
else {
$this
->assertEquals($data['value'], $this
->{$data['checker_callback']}($entity_translation, $field_machine_name), 'The data of the field ' . $field_machine_name . ' has been recreated.');
}
}
}
}
}
}
}