function TableSortExampleTest::testTableSortExampleLink

Same name in other branches
  1. 3.x modules/tablesort_example/tests/src/Functional/TableSortExampleTest.php \Drupal\Tests\tablesort_example\Functional\TableSortExampleTest::testTableSortExampleLink()
  2. 4.0.x modules/tablesort_example/tests/src/Functional/TableSortExampleTest.php \Drupal\Tests\tablesort_example\Functional\TableSortExampleTest::testTableSortExampleLink()

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

File

tablesort_example/tests/src/Functional/TableSortExampleTest.php, line 88

Class

TableSortExampleTest
Verify the tablesort functionality.

Namespace

Drupal\Tests\tablesort_example\Functional

Code

public function testTableSortExampleLink() {
    $assert = $this->assertSession();
    // Create a user with the permissions we need in order to display the
    // toolbar.
    $this->drupalLogin($this->createUser([
        'access content',
        'access toolbar',
    ]));
    // Our module's routes.
    $links = [
        '' => Url::fromRoute('tablesort_example.description'),
    ];
    // Go to the page and check that the link exists.
    foreach ($links as $page => $url) {
        $this->drupalGet($page);
        $assert->linkByHrefExists($url->getInternalPath());
    }
    // Visit the link and make sure we get a 200 back.
    foreach ($links as $url) {
        $this->drupalGet($url);
        $assert->statusCodeEquals(200);
    }
}