protected function EntityResourceTestBase::createAnotherEntity in Drupal 10
Same name and namespace in other branches
- 8 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::createAnotherEntity()
- 9 core/modules/rest/tests/src/Functional/EntityResource/EntityResourceTestBase.php \Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase::createAnotherEntity()
Creates another entity to be tested.
Return value
\Drupal\Core\Entity\EntityInterface Another entity based on $this->entity.
1 call to EntityResourceTestBase::createAnotherEntity()
- EntityResourceTestBase::testPatch in core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php - Tests a PATCH request for an entity, plus edge cases to ensure good DX.
1 method overrides EntityResourceTestBase::createAnotherEntity()
- WorkspaceResourceTestBase::createAnotherEntity in core/
modules/ workspaces/ tests/ src/ Functional/ EntityResource/ WorkspaceResourceTestBase.php - Creates another entity to be tested.
File
- core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php, line 254
Class
- EntityResourceTestBase
- Even though there is the generic EntityResource, it's necessary for every entity type to have its own test, because they each have different fields, validation constraints, et cetera. It's not because the generic case works, that every case…
Namespace
Drupal\Tests\rest\Functional\EntityResourceCode
protected function createAnotherEntity() {
$entity = $this->entity
->createDuplicate();
$label_key = $entity
->getEntityType()
->getKey('label');
if ($label_key) {
$entity
->set($label_key, $entity
->label() . '_dupe');
}
$entity
->save();
return $entity;
}