RenderExampleMenuTest.php in Examples for Developers 3.x
File
modules/render_example/tests/src/Functional/RenderExampleMenuTest.php
View source
<?php
namespace Drupal\Tests\render_example\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class RenderExampleMenuTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'render_example',
];
protected $profile = 'minimal';
public function testRenderExampleLinksExist() {
$this
->drupalLogin($this
->createUser([
'access content',
'access user profiles',
]));
$assertion = $this
->assertSession();
$routes = [
'render_example.description' => [],
'render_example.altering' => [
'Save configuration',
],
'render_example.arrays' => [],
];
$this
->drupalGet('');
foreach (array_keys($routes) as $route) {
$assertion
->linkByHrefExists(Url::fromRoute($route)
->getInternalPath());
}
$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);
}
}
}
}