public function RevisionBasicUITest::testRevisionRevert in Entity API 8
Same name and namespace in other branches
- 8.0 tests/src/Kernel/RevisionBasicUITest.php \Drupal\Tests\entity\Kernel\RevisionBasicUITest::testRevisionRevert()
File
- tests/
src/ Kernel/ RevisionBasicUITest.php, line 171
Class
- RevisionBasicUITest
- @group entity
Namespace
Drupal\Tests\entity\KernelCode
public function testRevisionRevert() {
$entity = EnhancedEntity::create([
'name' => 'rev 1',
'type' => 'entity_test_enhance',
]);
$entity
->save();
$entity->name->value = 'rev 2';
$entity
->setNewRevision(TRUE);
$entity
->isDefaultRevision(TRUE);
$entity
->save();
$role = Role::create([
'id' => 'test_role',
]);
$role
->grantPermission('administer entity_test_enhanced');
$role
->grantPermission('revert all entity_test_enhanced revisions');
$role
->save();
$user = User::create([
'name' => 'Test administrator',
]);
$user
->addRole($role
->id());
$user
->save();
$this->container
->get('account_switcher')
->switchTo($user);
/** @var \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel */
$http_kernel = $this->container
->get('http_kernel');
$request = Request::create($entity
->toUrl('revision-revert-form')
->toString());
$response = $http_kernel
->handle($request);
$this
->assertEquals(200, $response
->getStatusCode());
}