public function NodePreviewTest::testNodePreview in Entity Print 8
Same name and namespace in other branches
- 8.2 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 41
Class
- NodePreviewTest
- Tests the entity print link in node preview.
Namespace
Drupal\Tests\entity_print\KernelCode
public function testNodePreview() {
$this
->installSchema('system', [
'router',
]);
$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;
$display = EntityViewDisplay::create([
'targetEntityType' => 'node',
'bundle' => 'whatever',
'mode' => 'default',
'status' => TRUE,
])
->setComponent('entity_print_view');
$display
->save();
$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);
}