Chris@14: storage = $this->entityManager->getStorage('node'); Chris@14: $this->viewBuilder = $this->entityManager->getViewBuilder('node'); Chris@14: $this->renderer = $this->container->get('renderer'); Chris@14: Chris@14: $type = NodeType::create([ Chris@14: 'type' => 'article', Chris@14: 'name' => 'Article', Chris@14: ]); Chris@14: $type->save(); Chris@14: Chris@14: $this->installSchema('node', 'node_access'); Chris@14: $this->installConfig(['system', 'node']); Chris@14: } Chris@14: Chris@14: /** Chris@14: * Tests that node links are displayed correctly in pending revisions. Chris@14: * Chris@14: * @covers ::buildComponents Chris@14: * @covers ::renderLinks Chris@14: * @covers ::buildLinks Chris@14: */ Chris@14: public function testPendingRevisionLinks() { Chris@14: $account = User::create([ Chris@14: 'name' => $this->randomString(), Chris@14: ]); Chris@14: $account->save(); Chris@14: Chris@14: $title = $this->randomMachineName(); Chris@14: $node = Node::create([ Chris@14: 'type' => 'article', Chris@14: 'title' => $title, Chris@14: 'uid' => $account->id(), Chris@14: ]); Chris@14: $node->save(); Chris@14: Chris@14: /** @var \Drupal\node\NodeInterface $pending_revision */ Chris@14: $pending_revision = $this->storage->createRevision($node, FALSE); Chris@14: $draft_title = $title . ' draft'; Chris@14: $pending_revision->setTitle($draft_title); Chris@14: $pending_revision->save(); Chris@14: Chris@14: $build = $this->viewBuilder->view($node, 'teaser'); Chris@14: $output = (string) $this->renderer->renderPlain($build); Chris@14: $this->assertContains("title=\"$title\"", $output); Chris@14: Chris@14: $build = $this->viewBuilder->view($pending_revision, 'teaser'); Chris@14: $output = (string) $this->renderer->renderPlain($build); Chris@14: $this->assertContains("title=\"$draft_title\"", $output); Chris@14: } Chris@14: Chris@14: }