function EntityApiTest::testUpdateWithRevisionId
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php \Drupal\KernelTests\Core\Entity\EntityApiTest::testUpdateWithRevisionId()
- 10 core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php \Drupal\KernelTests\Core\Entity\EntityApiTest::testUpdateWithRevisionId()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityApiTest.php \Drupal\KernelTests\Core\Entity\EntityApiTest::testUpdateWithRevisionId()
Tests that resaving a revision with a different revision ID throws an exception.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityApiTest.php, line 247
Class
- EntityApiTest
- Tests basic CRUD functionality.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testUpdateWithRevisionId() {
$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 revision while changing the revision ID is not supported.");
$entity->revision_id = 60;
$entity->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.