function EntityRevisionTranslationTest::testSetNewRevision
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testSetNewRevision()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testSetNewRevision()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityRevisionTranslationTest.php \Drupal\KernelTests\Core\Entity\EntityRevisionTranslationTest::testSetNewRevision()
@covers \Drupal\Core\Entity\ContentEntityBase::setNewRevision
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityRevisionTranslationTest.php, line 173
Class
- EntityRevisionTranslationTest
- Tests proper revision propagation of entities.
Namespace
Drupal\KernelTests\Core\EntityCode
public function testSetNewRevision() : void {
$user = $this->createUser();
// All revisionable entity variations have to have the same results.
foreach (entity_test_entity_types(ENTITY_TEST_TYPES_REVISABLE) as $entity_type) {
$this->installEntitySchema($entity_type);
$storage = \Drupal::entityTypeManager()->getStorage($entity_type);
$entity = $storage->create([
'name' => 'foo',
'user_id' => $user->id(),
]);
$entity->save();
$entity_id = $entity->id();
$entity_rev_id = $entity->getRevisionId();
$entity = $storage->loadUnchanged($entity_id);
$entity->setNewRevision(TRUE);
$entity->setNewRevision(FALSE);
$entity->save();
$entity = $storage->loadUnchanged($entity_id);
$this->assertEquals($entity_rev_id, $entity->getRevisionId(), 'A new entity revision was not created.');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.