public function NodeViewTest::testWithCustomViewMode in Node Option Premium 8
Tests if premium message is shown on custom view mode by default.
File
- tests/
src/ Kernel/ NodeViewTest.php, line 112
Class
- NodeViewTest
- Tests displaying nodes.
Namespace
Drupal\Tests\nopremium\KernelCode
public function testWithCustomViewMode() {
$this
->createViewModeAndDisplay('foo');
// Create a premium node.
$node = $this
->createNodeWithBodyValue('Lorem ipsum', [
'premium' => TRUE,
]);
$build = $this->viewBuilder
->view($node, 'foo');
$output = (string) $this->renderer
->renderPlain($build);
$this
->assertStringContainsString('The full content of this page is available to premium users only.', $output);
$this
->assertStringNotContainsString('Lorem ipsum', $output);
}