function DemoUmamiProfileTest::assertDemonstrationWarningMessage
Asserts if the demonstration warning message is displayed properly.
Parameters
array $permissions: The user permissions needed to make the assertions.
2 calls to DemoUmamiProfileTest::assertDemonstrationWarningMessage()
- DemoUmamiProfileTest::testDemonstrationWarningMessage in core/
profiles/ demo_umami/ tests/ src/ Functional/ DemoUmamiProfileTest.php - Tests that the toolbar warning only appears on the admin pages.
- DemoUmamiProfileTest::testNavigationDemonstrationWarningMessage in core/
profiles/ demo_umami/ tests/ src/ Functional/ DemoUmamiProfileTest.php - Tests that the navigation warning only appears on the admin pages.
File
-
core/
profiles/ demo_umami/ tests/ src/ Functional/ DemoUmamiProfileTest.php, line 289
Class
- DemoUmamiProfileTest
- Tests demo_umami profile.
Namespace
Drupal\Tests\demo_umami\FunctionalCode
protected function assertDemonstrationWarningMessage(array $permissions) : void {
$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.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.