You are here

public function FrontPageLinkTest::testAddContentMenuItem in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/testing_example/tests/src/Functional/FrontPageLinkTest.php \Drupal\Tests\testing_example\Functional\FrontPageLinkTest::testAddContentMenuItem()

Tests for the existence of a default menu item on the home page.

We'll open the home page and look for the Tools menu link called 'Add content.'

File

testing_example/tests/src/Functional/FrontPageLinkTest.php, line 39

Class

FrontPageLinkTest
Tests for the existence of links on the front page.

Namespace

Drupal\Tests\testing_example\Functional

Code

public function testAddContentMenuItem() {

  // Step 1: Log in a user who can add content.
  $this
    ->drupalLogin($this
    ->createUser([
    'create article content',
  ]));

  // Step 2: Visit the home path.
  $this
    ->drupalGet($this
    ->buildUrl(''));

  // Step 3: Look on the page for the 'Add content' link.
  $this
    ->assertSession()
    ->linkExists('Add content');
}