public function PHPUnitExampleMenuTest::testLinksAndPages in Examples for Developers 3.x
Same name and namespace in other branches
- 8 phpunit_example/tests/src/Functional/PHPUnitExampleMenuTest.php \Drupal\Tests\phpunit_example\Functional\PHPUnitExampleMenuTest::testLinksAndPages()
Verify and validate that default menu links were loaded for this module.
File
- modules/
phpunit_example/ tests/ src/ Functional/ PHPUnitExampleMenuTest.php, line 46
Class
- PHPUnitExampleMenuTest
- Test the user-facing menus in PHPUnit Example.
Namespace
Drupal\Tests\phpunit_example\FunctionalCode
public function testLinksAndPages() {
$this
->drupalLogin($this
->createUser([
'access content',
]));
$assert = $this
->assertSession();
$links = [
'' => Url::fromRoute('phpunit_example.description'),
];
// Go to the page and see if the link appears on it.
foreach ($links as $page => $path) {
$this
->drupalGet($page);
$assert
->linkByHrefExists($path
->getInternalPath());
}
// Visit all the links and make sure they return 200.
foreach ($links as $path) {
$this
->drupalGet($path);
$assert
->statusCodeEquals(200);
}
}