public function DbtngExampleTest::testDbtngExample in Examples for Developers 8
Same name and namespace in other branches
- 3.x modules/dbtng_example/tests/src/Functional/DbtngExampleTest.php \Drupal\Tests\dbtng_example\Functional\DbtngExampleTest::testDbtngExample()
Regression test for dbtng_example.
We'll verify the following:
- Assert that two entries were inserted at install.
- Test the example description page.
- Verify that the example pages have links in the Tools menu.
File
- dbtng_example/
tests/ src/ Functional/ DbtngExampleTest.php, line 47
Class
- DbtngExampleTest
- Tests for the dbtng_example module.
Namespace
Drupal\Tests\dbtng_example\FunctionalCode
public function testDbtngExample() {
$assert = $this
->assertSession();
// Assert that two entries were inserted at install.
$result = $this->container
->get('dbtng_example.repository')
->load();
$this
->assertCount(2, $result, 'Did not find two entries in the table after installing the module.');
// Test the example description page.
$this
->drupalGet('/examples/dbtng-example');
$assert
->statusCodeEquals(200);
// Verify and validate that default menu links were loaded for this module.
$links = $this
->providerMenuLinks();
foreach ($links as $page => $hrefs) {
foreach ($hrefs as $href) {
$this
->drupalGet($page);
$assert
->linkByHrefExists($href);
}
}
}