You are here

public function NodeViewTest::testViewPremiumNode in Node Option Premium 8

Same name in this branch
  1. 8 tests/src/Functional/NodeViewTest.php \Drupal\Tests\nopremium\Functional\NodeViewTest::testViewPremiumNode()
  2. 8 tests/src/Kernel/NodeViewTest.php \Drupal\Tests\nopremium\Kernel\NodeViewTest::testViewPremiumNode()

Tests that the premium message is displayed for a premium node.

File

tests/src/Functional/NodeViewTest.php, line 56

Class

NodeViewTest
Tests displaying nodes.

Namespace

Drupal\Tests\nopremium\Functional

Code

public function testViewPremiumNode() {

  // Create a premium node.
  $node = $this
    ->createNodeWithBodyValue('Lorem ipsum', [
    'premium' => TRUE,
  ]);
  $this
    ->drupalGet($node
    ->toUrl());
  $this
    ->assertSession()
    ->pageTextNotContains('Lorem ipsum');
  $this
    ->assertSession()
    ->pageTextContains('The full content of this page is available to premium users only.');

  // Ensure that there is no read more link, since we're on the full content
  // page already.
  $this
    ->assertSession()
    ->pageTextNotContains('Read more');

  // And ensure that there's no link to the node.
  $this
    ->assertSession()
    ->linkNotExists($node
    ->label());
}