class PHPUnitExampleMenuTest
Same name in other branches
- 3.x modules/phpunit_example/tests/src/Functional/PHPUnitExampleMenuTest.php \Drupal\Tests\phpunit_example\Functional\PHPUnitExampleMenuTest
- 4.0.x modules/phpunit_example/tests/src/Functional/PHPUnitExampleMenuTest.php \Drupal\Tests\phpunit_example\Functional\PHPUnitExampleMenuTest
Test the user-facing menus in PHPUnit Example.
Note that this is _not_ a PHPUnit-based test. It's a functional test of whether this module can be enabled properly.
@group phpunit_example @group examples
Hierarchy
- class \Drupal\Tests\phpunit_example\Functional\PHPUnitExampleMenuTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of PHPUnitExampleMenuTest
Related topics
File
-
phpunit_example/
tests/ src/ Functional/ PHPUnitExampleMenuTest.php, line 19
Namespace
Drupal\Tests\phpunit_example\FunctionalView source
class PHPUnitExampleMenuTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'phpunit_example',
];
/**
* The installation profile to use with this test.
*
* We need the 'minimal' profile in order to make sure the Tool block is
* available.
*
* @var string
*/
protected $profile = 'minimal';
/**
* Verify and validate that default menu links were loaded for this module.
*/
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);
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
PHPUnitExampleMenuTest::$defaultTheme | protected | property | |
PHPUnitExampleMenuTest::$modules | public static | property | Modules to enable. |
PHPUnitExampleMenuTest::$profile | protected | property | The installation profile to use with this test. |
PHPUnitExampleMenuTest::testLinksAndPages | public | function | Verify and validate that default menu links were loaded for this module. |