public function EntityApiTest::testUpdateWithId in Drupal 9
Same name and namespace in other branches
- 8 core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php \Drupal\KernelTests\Core\Entity\EntityApiTest::testUpdateWithId()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php \Drupal\KernelTests\Core\Entity\EntityApiTest::testUpdateWithId()
Tests that resaving an entity with a different entity ID throws an exception.
File
- core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityApiTest.php, line 267
Class
- EntityApiTest
- Tests basic CRUD functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testUpdateWithId() {
$storage = \Drupal::entityTypeManager()
->getStorage('entity_test_mulrev');
// Create a new entity.
/** @var \Drupal\entity_test\Entity\EntityTestMulRev $entity */
$entity = $storage
->create([
'name' => 'revision_test',
]);
$entity
->save();
$this
->expectException(EntityStorageException::class);
$this
->expectExceptionMessage("Update existing 'entity_test_mulrev' entity while changing the ID is not supported.");
$entity->id = 60;
$entity
->save();
}