3 final class AphrontRoutingMapTestCase
4 extends PhabricatorTestCase
{
6 public function testRoutingMaps() {
9 $sites = AphrontSite
::getAllSites();
10 foreach ($sites as $site) {
11 $maps = $site->getRoutingMaps();
12 foreach ($maps as $map) {
13 foreach ($map->getRoutes() as $rule => $value) {
14 $this->assertRoutable($site, $map, array(), $rule, $value);
22 pht('No sites define any routing rules.'));
26 private function assertRoutable(
28 AphrontRoutingMap
$map,
35 $site_description = $site->getDescription();
36 $rule_path = implode(' > ', $path);
38 $pattern = implode('', $path);
39 $pattern = '('.$pattern.')';
40 $ok = @preg_match
($pattern, '');
45 'Routing rule ("%s", for site "%s") does not compile into a '.
46 'valid regular expression.',
50 if (is_array($value)) {
54 'Routing rule ("%s", for site "%s") does not have any targets.',
58 foreach ($value as $sub_rule => $sub_value) {
59 $this->assertRoutable($site, $map, $path, $sub_rule, $sub_value);
64 if (is_string($value)) {
68 'Routing rule ("%s", for site "%s") points at controller ("%s") '.
69 'which does not exist.',
78 'Routing rule ("%s", for site "%s") points at unknown value '.
79 '(of type "%s"), expected a controller class name string.',
82 phutil_describe_type($value)));