protected function EntityShareClientFunctionalTestBase::prepareContent 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::prepareContent()
Helper function to create the content required for the tests.
8 calls to EntityShareClientFunctionalTestBase::prepareContent()
- EntityShareClientFunctionalTestBase::postSetupFixture in modules/
entity_share_client/ tests/ src/ Functional/ EntityShareClientFunctionalTestBase.php - Helper function.
- FileDeletedTest::postSetupFixture in modules/
entity_share_client/ tests/ src/ Functional/ FileDeletedTest.php - Helper function.
- FileTest::postSetupFixture in modules/
entity_share_client/ tests/ src/ Functional/ FileTest.php - Helper function.
- MetatagTest::testExposeDefaultTags in modules/
entity_share_client/ tests/ src/ Functional/ MetatagTest.php - Test metatag plugin.
- MetatagTest::testExposeDefaultTagsAndTokenReplace in modules/
entity_share_client/ tests/ src/ Functional/ MetatagTest.php - Test metatag plugin.
1 method overrides EntityShareClientFunctionalTestBase::prepareContent()
- InfiniteLoopTest::prepareContent in modules/
entity_share_client/ tests/ src/ Functional/ InfiniteLoopTest.php - Helper function to create the content required for the tests.
File
- modules/
entity_share_client/ tests/ src/ Functional/ EntityShareClientFunctionalTestBase.php, line 289
Class
- EntityShareClientFunctionalTestBase
- Base class for Entity share server functional tests.
Namespace
Drupal\Tests\entity_share_client\FunctionalCode
protected function prepareContent() {
$entities_data = $this
->getEntitiesData();
foreach ($entities_data as $entity_type_id => $data_per_languages) {
$entity_storage = $this->entityTypeManager
->getStorage($entity_type_id);
if (!isset($this->entities[$entity_type_id])) {
$this->entities[$entity_type_id] = [];
}
foreach ($data_per_languages as $langcode => $entity_data) {
foreach ($entity_data as $entity_uuid => $entity_data_per_field) {
// If the entity has already been created, create a translation.
if (isset($this->entities[$entity_type_id][$entity_uuid])) {
$prepared_entity_data = $this
->prepareEntityData($entity_data_per_field);
$entity = $this->entities[$entity_type_id][$entity_uuid];
$entity
->addTranslation($langcode, $prepared_entity_data);
$entity
->save();
}
else {
$entity_data_per_field += [
'langcode' => [
'value' => $langcode,
'checker_callback' => 'getValue',
],
'uuid' => [
'value' => $entity_uuid,
'checker_callback' => 'getValue',
],
];
$prepared_entity_data = $this
->prepareEntityData($entity_data_per_field);
$entity = $entity_storage
->create($prepared_entity_data);
$entity
->save();
}
$this->entities[$entity_type_id][$entity_uuid] = $entity;
}
}
}
}