class RenderExampleMenuTest
Same name in other branches
- 3.x modules/render_example/tests/src/Functional/RenderExampleMenuTest.php \Drupal\Tests\render_example\Functional\RenderExampleMenuTest
- 4.0.x modules/render_example/tests/src/Functional/RenderExampleMenuTest.php \Drupal\Tests\render_example\Functional\RenderExampleMenuTest
Test the user-facing menus in Render Example.
@group render_example @group examples
Hierarchy
- class \Drupal\Tests\render_example\Functional\RenderExampleMenuTest extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of RenderExampleMenuTest
Related topics
File
-
render_example/
tests/ src/ Functional/ RenderExampleMenuTest.php, line 16
Namespace
Drupal\Tests\render_example\FunctionalView source
class RenderExampleMenuTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'render_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 testRenderExampleLinksExist() {
// Login a user that can access content.
$this->drupalLogin($this->createUser([
'access content',
'access user profiles',
]));
$assertion = $this->assertSession();
// Routes with menu links, and their form buttons.
$routes = [
'render_example.description' => [],
'render_example.altering' => [
'Save configuration',
],
'render_example.arrays' => [],
];
// Ensure the links appear in the tools menu sidebar.
$this->drupalGet('');
foreach (array_keys($routes) as $route) {
$assertion->linkByHrefExists(Url::fromRoute($route)->getInternalPath());
}
// Go to all the routes and click all the buttons.
$routes = array_merge($routes, $routes);
foreach ($routes as $route => $buttons) {
$path = Url::fromRoute($route);
$this->drupalGet($path);
$assertion->statusCodeEquals(200);
foreach ($buttons as $button) {
$this->drupalPostForm($path, [], $button);
$assertion->statusCodeEquals(200);
}
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
RenderExampleMenuTest::$defaultTheme | protected | property | |
RenderExampleMenuTest::$modules | public static | property | Modules to enable. |
RenderExampleMenuTest::$profile | protected | property | The installation profile to use with this test. |
RenderExampleMenuTest::testRenderExampleLinksExist | public | function | Verify and validate that default menu links were loaded for this module. |