You are here

public function DemoUmamiProfileTest::testDemonstrationWarningMessage in Drupal 8

Same name and namespace in other branches
  1. 9 core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testDemonstrationWarningMessage()

Tests that the toolbar warning only appears on the admin pages.

File

core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php, line 148

Class

DemoUmamiProfileTest
Tests demo_umami profile.

Namespace

Drupal\Tests\demo_umami\Functional

Code

public function testDemonstrationWarningMessage() {
  $permissions = [
    'access content overview',
    'access toolbar',
    'administer nodes',
    'edit any recipe content',
    'create recipe content',
    'use editorial transition create_new_draft',
  ];
  $account = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($account);
  $web_assert = $this
    ->assertSession();
  $nodes = $this->container
    ->get('entity_type.manager')
    ->getStorage('node')
    ->loadByProperties([
    'title' => 'Deep mediterranean quiche',
  ]);

  /* @var \Drupal\node\Entity\Node $recipe_node */
  $recipe_node = reset($nodes);

  // Check when editing a node, the warning is visible.
  $this
    ->drupalGet($recipe_node
    ->toUrl('edit-form'));
  $web_assert
    ->statusCodeEquals('200');
  $web_assert
    ->pageTextContains('This site is intended for demonstration purposes.');

  // Check when adding a node, the warning is visible.
  $this
    ->drupalGet('node/add/recipe');
  $web_assert
    ->statusCodeEquals('200');
  $web_assert
    ->pageTextContains('This site is intended for demonstration purposes.');

  // Check when looking at admin/content, the warning is visible.
  $this
    ->drupalGet('admin/content');
  $web_assert
    ->statusCodeEquals('200');
  $web_assert
    ->pageTextContains('This site is intended for demonstration purposes.');

  // Check when viewing a node, the warning is not visible.
  $this
    ->drupalGet($recipe_node
    ->toUrl());
  $web_assert
    ->statusCodeEquals('200');
  $web_assert
    ->pageTextNotContains('This site is intended for demonstration purposes.');

  // Check when viewing the homepage, the warning is not visible.
  $this
    ->drupalGet('<front>');
  $web_assert
    ->statusCodeEquals('200');
  $web_assert
    ->pageTextNotContains('This site is intended for demonstration purposes.');
}