protected function ResourceTestBase::getEntityDuplicate in JSON:API 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getEntityDuplicate()
4 calls to ResourceTestBase::getEntityDuplicate()
- FeedTest::createAnotherEntity in tests/
src/ Functional/ FeedTest.php - Creates another entity to be tested.
- ItemTest::createAnotherEntity in tests/
src/ Functional/ ItemTest.php - Creates another entity to be tested.
- ResourceTestBase::createAnotherEntity in tests/
src/ Functional/ ResourceTestBase.php - Creates another entity to be tested.
- UserTest::createAnotherEntity in tests/
src/ Functional/ UserTest.php - Creates another entity to be tested.
File
- tests/
src/ Functional/ ResourceTestBase.php, line 364
Class
- ResourceTestBase
- Subclass this for every JSON API resource type.
Namespace
Drupal\Tests\jsonapi\FunctionalCode
protected function getEntityDuplicate(EntityInterface $original, $key) {
$duplicate = $original
->createDuplicate();
if ($label_key = $original
->getEntityType()
->getKey('label')) {
$duplicate
->set($label_key, $original
->label() . '_' . $key);
}
if ($duplicate instanceof ConfigEntityInterface && ($id_key = $duplicate
->getEntityType()
->getKey('id'))) {
$id = $original
->id();
$id_key = $duplicate
->getEntityType()
->getKey('id');
$duplicate
->set($id_key, $id . '_' . $key);
}
return $duplicate;
}