You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/tests/RouteTargetTest.php

20 lines
772 B
PHP

<?php
require dirname(__DIR__) . '/vendor/autoload.php';
$routes = file_get_contents(dirname(__DIR__) . '/config/routes.php') . "\n"
. file_get_contents(dirname(__DIR__) . '/config/routes_cloud.php');
preg_match_all("/'(App\\\\Controllers\\\\[^']+):([^']+)'/", $routes, $matches, PREG_SET_ORDER);
$count = 0;
foreach ($matches as $match) {
if (!class_exists($match[1]) || !method_exists($match[1], $match[2])) {
throw new RuntimeException('Unresolved route target: ' . $match[1] . ':' . $match[2]);
}
$method = new ReflectionMethod($match[1], $match[2]);
if (!$method->isPublic()) {
throw new RuntimeException('Nonpublic route target');
}
$count++;
}
echo 'Route targets resolved without application boot: ' . $count . ".\n";