protected function ResourceTestBase::getEntityDuplicate in Drupal 9
Same name and namespace in other branches
- 8 core/modules/jsonapi/tests/src/Functional/ResourceTestBase.php \Drupal\Tests\jsonapi\Functional\ResourceTestBase::getEntityDuplicate()
4 calls to ResourceTestBase::getEntityDuplicate()
- FeedTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ FeedTest.php - Creates another entity to be tested.
- ItemTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ ItemTest.php - Creates another entity to be tested.
- ResourceTestBase::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php - Creates another entity to be tested.
- UserTest::createAnotherEntity in core/
modules/ jsonapi/ tests/ src/ Functional/ UserTest.php - Creates another entity to be tested.
File
- core/
modules/ jsonapi/ tests/ src/ Functional/ ResourceTestBase.php, line 424
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();
$duplicate
->set($id_key, $id . '_' . $key);
}
return $duplicate;
}