You are here

public function NodePreviewTest::testNodePreview in Entity Print 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/NodePreviewTest.php \Drupal\Tests\entity_print\Kernel\NodePreviewTest::testNodePreview()

Tests that entity print link is not displayed in node preview.

File

tests/src/Kernel/NodePreviewTest.php, line 40

Class

NodePreviewTest
Tests the entity print link in node preview.

Namespace

Drupal\Tests\entity_print\Kernel

Code

public function testNodePreview() {
  $this
    ->installConfig([
    'system',
    'user',
  ]);
  $this
    ->config('system.theme.global')
    ->set('features.node_user_picture', FALSE)
    ->save();
  $this
    ->installEntitySchema('user');
  $this
    ->installEntitySchema('node');
  $this->container
    ->get('router.builder')
    ->rebuild();
  NodeType::create([
    'type' => 'whatever',
    'name' => 'What?',
  ])
    ->save();

  // Deliberately we are not saving the node, so the node misses the ID.
  $node = Node::create([
    'type' => 'whatever',
    'title' => 'Buzz',
  ]);
  $node->in_preview = TRUE;
  $controller = NodePreviewController::create($this->container);
  $build = $controller
    ->view($node);

  /** @var \Drupal\Core\Render\RendererInterface $renderer */
  $renderer = $this->container
    ->get('renderer');
  $renderer
    ->renderPlain($build);
  $this
    ->assertNotError("array_flip(): Can only flip STRING and INTEGER values!", E_WARNING);
}