/** * @covers ::revisionIds */ public function testRevisionIds() { $entity = CebTestContent::create(['type' => 'ceb_test_content']); $entity->save(); $revision_ids = $this->getStorage()->revisionIds($entity); $this->assertCount(1, $revision_ids); $this->assertEquals([$entity->getRevisionId()], $revision_ids); $old_revision = clone $entity; $entity->setNewRevision(TRUE); $entity->save(); $expected_ids = [$old_revision->getRevisionId(), $entity->getRevisionId()]; $revision_ids = $this->getStorage()->revisionIds($entity); $this->assertCount(2, $revision_ids); $this->assertEquals($expected_ids, $revision_ids); }
public function testRevisionHistoryPagesWithMoreThanOneRevision() { /** @var \Drupal\Core\Session\AccountSwitcherInterface $account_switcher */ $account_switcher = \Drupal::service('account_switcher'); /** @var \Drupal\content_entity_base\Entity\Routing\EntityRevisionRouteAccessChecker $revision_access_check */ $revision_access_check = \Drupal::service('content_entity_base.entity_revision_access_checker'); $entity = CebTestContent::create(['type' => 'test_bundle']); $entity->save(); $entity->setNewRevision(TRUE); $entity->save(); $user = $this->drupalCreateUser(['access ceb_test_content']); $account_switcher->switchTo($user); $response = $this->httpKernel->handle(Request::create($entity->url('version-history'))); $this->assertEquals(403, $response->getStatusCode()); $revision_access_check->resetAccessCache(); $user = $this->drupalCreateUser(['access ceb_test_content', 'view all ceb_test_content revisions']); $account_switcher->switchTo($user); $response = $this->httpKernel->handle(Request::create($entity->url('version-history'))); $this->assertEquals(200, $response->getStatusCode()); $this->setRawContent($response->getContent()); $this->assertText('Current revision'); // Ensure that we have a link to the current and prevision revision. $this->assertLinkByHref($entity->url('canonical')); $this->assertLinkByHref($entity->url('revision')); }