You are here

public function PageExampleTest::testPageExampleLinks in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 page_example/tests/src/Functional/PageExampleTest.php \Drupal\Tests\page_example\Functional\PageExampleTest::testPageExampleLinks()

Verify and validate that default menu links were loaded for this module.

@dataProvider providerMenuLinks

File

modules/page_example/tests/src/Functional/PageExampleTest.php, line 104

Class

PageExampleTest
Creates page and render the content based on the arguments passed in the URL.

Namespace

Drupal\Tests\page_example\Functional

Code

public function testPageExampleLinks($permission, $links) {
  if ($permission) {
    $user = $this
      ->drupalCreateUser([
      $permission,
    ]);
    $this
      ->drupalLogin($user);
  }
  foreach ($links as $page => $path) {
    $this
      ->drupalGet($page);
    $this
      ->assertSession()
      ->linkByHrefExists($path);
  }
  if ($permission) {
    $this
      ->drupalLogout();
  }
}