Namespace
Drupal\Tests\examples\Unit
File
-
tests/src/Unit/RoutePathTest.php
View source
<?php
namespace Drupal\Tests\examples\Unit;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\Yaml\Yaml;
class RoutePathTest extends UnitTestCase {
use FilesTestTrait;
use RetrieveRoutingFilesTrait;
public static function providerRoutingFiles() : array {
$data = [];
$directory = self::projectPathname('modules');
return self::retrieveFiles($directory, 'yml', self::routingFilesCallback(...));
}
public function testPathStartsWithSlash(string $filename, string $path, string $pathname) : void {
$routes = Yaml::parse(file_get_contents($pathname));
foreach ($routes as $name => $route) {
if (isset($route['path'])) {
$this->assertEquals('/', $route['path'][0], "{$filename} in {$path} contains a route ({$name}) that does not start with a slash.");
}
}
}
}
Classes
| Title |
Deprecated |
Summary |
| RoutePathTest |
|
Verifies route paths are valid. |