diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 0728a08273..7733db206f 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -275,6 +275,7 @@ phutil_register_library_map(array( 'AphrontResponse' => 'aphront/response/AphrontResponse.php', 'AphrontResponseProducerInterface' => 'aphront/interface/AphrontResponseProducerInterface.php', 'AphrontRoutingMap' => 'aphront/site/AphrontRoutingMap.php', + 'AphrontRoutingMapTestCase' => 'aphront/__tests__/AphrontRoutingMapTestCase.php', 'AphrontRoutingResult' => 'aphront/site/AphrontRoutingResult.php', 'AphrontSchemaQueryException' => 'infrastructure/storage/exception/AphrontSchemaQueryException.php', 'AphrontScopedUnguardedWriteCapability' => 'aphront/writeguard/AphrontScopedUnguardedWriteCapability.php', @@ -6283,6 +6284,7 @@ phutil_register_library_map(array( 'AphrontRequestTestCase' => 'PhabricatorTestCase', 'AphrontResponse' => 'Phobject', 'AphrontRoutingMap' => 'Phobject', + 'AphrontRoutingMapTestCase' => 'PhabricatorTestCase', 'AphrontRoutingResult' => 'Phobject', 'AphrontSchemaQueryException' => 'AphrontQueryException', 'AphrontScopedUnguardedWriteCapability' => 'Phobject', diff --git a/src/aphront/__tests__/AphrontRoutingMapTestCase.php b/src/aphront/__tests__/AphrontRoutingMapTestCase.php new file mode 100644 index 0000000000..42d79d1089 --- /dev/null +++ b/src/aphront/__tests__/AphrontRoutingMapTestCase.php @@ -0,0 +1,85 @@ +getRoutingMaps(); + foreach ($maps as $map) { + foreach ($map->getRoutes() as $rule => $value) { + $this->assertRoutable($site, $map, array(), $rule, $value); + $count++; + } + } + } + + if (!$count) { + $this->assertSkipped( + pht('No sites define any routing rules.')); + } + } + + private function assertRoutable( + AphrontSite $site, + AphrontRoutingMap $map, + array $path, + $rule, + $value) { + + $path[] = $rule; + + $site_description = $site->getDescription(); + $rule_path = implode(' > ', $path); + + $pattern = implode('', $path); + $pattern = '('.$pattern.')'; + $ok = @preg_match($pattern, ''); + + $this->assertTrue( + ($ok !== false), + pht( + 'Routing rule ("%s", for site "%s") does not compile into a '. + 'valid regular expression.', + $rule_path, + $site_description)); + + if (is_array($value)) { + $this->assertTrue( + (count($value) > 0), + pht( + 'Routing rule ("%s", for site "%s") does not have any targets.', + $rule_path, + $site_description)); + + foreach ($value as $sub_rule => $sub_value) { + $this->assertRoutable($site, $map, $path, $sub_rule, $sub_value); + } + return; + } + + if (is_string($value)) { + $this->assertTrue( + class_exists($value), + pht( + 'Routing rule ("%s", for site "%s") points at controller ("%s") '. + 'which does not exist.', + $rule_path, + $site_description, + $value)); + return; + } + + $this->assertFailure( + pht( + 'Routing rule ("%s", for site "%s") points at unknown value '. + '(of type "%s"), expected a controller class name string.', + $rule_path, + $site_description, + phutil_describe_type($value))); + } + +} diff --git a/src/applications/config/application/PhabricatorConfigApplication.php b/src/applications/config/application/PhabricatorConfigApplication.php index 0e5e5972e1..e7a1b7eb1b 100644 --- a/src/applications/config/application/PhabricatorConfigApplication.php +++ b/src/applications/config/application/PhabricatorConfigApplication.php @@ -38,11 +38,7 @@ final class PhabricatorConfigApplication extends PhabricatorApplication { return array( '/config/' => array( '' => 'PhabricatorConfigConsoleController', - 'application/' => 'PhabricatorConfigApplicationController', - 'all/' => 'PhabricatorConfigAllController', - 'history/' => 'PhabricatorConfigHistoryController', 'edit/(?P[\w\.\-]+)/' => 'PhabricatorConfigEditController', - 'group/(?P[^/]+)/' => 'PhabricatorConfigGroupController', 'database/'. '(?:(?P[^/]+)/'. '(?:(?P[^/]+)/'. diff --git a/src/applications/countdown/application/PhabricatorCountdownApplication.php b/src/applications/countdown/application/PhabricatorCountdownApplication.php index 6cead5a01c..b3b5a79da2 100644 --- a/src/applications/countdown/application/PhabricatorCountdownApplication.php +++ b/src/applications/countdown/application/PhabricatorCountdownApplication.php @@ -42,8 +42,6 @@ final class PhabricatorCountdownApplication extends PhabricatorApplication { '/countdown/' => array( '(?:query/(?P[^/]+)/)?' => 'PhabricatorCountdownListController', - 'comment/(?P[1-9]\d*)/' - => 'PhabricatorCountdownCommentController', $this->getEditRoutePattern('edit/') => 'PhabricatorCountdownEditController', ), diff --git a/src/applications/differential/application/PhabricatorDifferentialApplication.php b/src/applications/differential/application/PhabricatorDifferentialApplication.php index c27d0da820..b1312228d1 100644 --- a/src/applications/differential/application/PhabricatorDifferentialApplication.php +++ b/src/applications/differential/application/PhabricatorDifferentialApplication.php @@ -76,11 +76,7 @@ final class PhabricatorDifferentialApplication => 'DifferentialRevisionInlinesController', ), 'comment/' => array( - 'preview/(?P[1-9]\d*)/' => 'DifferentialCommentPreviewController', - 'save/(?P[1-9]\d*)/' => 'DifferentialCommentSaveController', 'inline/' => array( - 'preview/(?P[1-9]\d*)/' - => 'DifferentialInlineCommentPreviewController', 'edit/(?P[1-9]\d*)/' => 'DifferentialInlineCommentEditController', ), diff --git a/src/applications/files/application/PhabricatorFilesApplication.php b/src/applications/files/application/PhabricatorFilesApplication.php index 14bbd83e78..2e4c48f0d6 100644 --- a/src/applications/files/application/PhabricatorFilesApplication.php +++ b/src/applications/files/application/PhabricatorFilesApplication.php @@ -81,7 +81,6 @@ final class PhabricatorFilesApplication extends PhabricatorApplication { 'upload/' => 'PhabricatorFileUploadController', 'dropupload/' => 'PhabricatorFileDropUploadController', 'compose/' => 'PhabricatorFileComposeController', - 'comment/(?P[1-9]\d*)/' => 'PhabricatorFileCommentController', 'thread/(?P[^/]+)/' => 'PhabricatorFileLightboxController', 'delete/(?P[1-9]\d*)/' => 'PhabricatorFileDeleteController', $this->getEditRoutePattern('edit/') diff --git a/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php b/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php index 4b369e821e..57f04e550b 100644 --- a/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php +++ b/src/applications/harbormaster/application/PhabricatorHarbormasterApplication.php @@ -81,7 +81,6 @@ final class PhabricatorHarbormasterApplication extends PhabricatorApplication { $this->getQueryRoutePattern() => 'HarbormasterPlanListController', $this->getEditRoutePattern('edit/') => 'HarbormasterPlanEditController', - 'order/(?:(?P\d+)/)?' => 'HarbormasterPlanOrderController', 'disable/(?P\d+)/' => 'HarbormasterPlanDisableController', 'behavior/(?P\d+)/(?P[^/]+)/' => 'HarbormasterPlanBehaviorController', diff --git a/src/applications/people/application/PhabricatorPeopleApplication.php b/src/applications/people/application/PhabricatorPeopleApplication.php index ec6892d022..86c03fdf4b 100644 --- a/src/applications/people/application/PhabricatorPeopleApplication.php +++ b/src/applications/people/application/PhabricatorPeopleApplication.php @@ -81,8 +81,6 @@ final class PhabricatorPeopleApplication extends PhabricatorApplication { ), '/p/(?P[\w._-]+)/' => array( '' => 'PhabricatorPeopleProfileViewController', - 'item/' => $this->getProfileMenuRouting( - 'PhabricatorPeopleProfileMenuController'), ), ); } diff --git a/src/applications/phame/application/PhabricatorPhameApplication.php b/src/applications/phame/application/PhabricatorPhameApplication.php index 9342076ddd..9b85a827c1 100644 --- a/src/applications/phame/application/PhabricatorPhameApplication.php +++ b/src/applications/phame/application/PhabricatorPhameApplication.php @@ -49,7 +49,6 @@ final class PhabricatorPhameApplication extends PhabricatorApplication { 'view/(?P\d+)/(?:(?P[^/]+)/)?' => 'PhamePostViewController', '(?Ppublish|unpublish)/(?P\d+)/' => 'PhamePostPublishController', - 'preview/(?P\d+)/' => 'PhamePostPreviewController', 'preview/' => 'PhabricatorMarkupPreviewController', 'move/(?P\d+)/' => 'PhamePostMoveController', 'archive/(?P\d+)/' => 'PhamePostArchiveController', @@ -66,20 +65,7 @@ final class PhabricatorPhameApplication extends PhabricatorApplication { 'picture/(?P[1-9]\d*)/' => 'PhameBlogProfilePictureController', 'header/(?P[1-9]\d*)/' => 'PhameBlogHeaderPictureController', ), - ) + $this->getResourceSubroutes(), - ); - } - - public function getResourceRoutes() { - return array( - '/phame/' => $this->getResourceSubroutes(), - ); - } - - private function getResourceSubroutes() { - return array( - 'r/(?P\d+)/(?P[^/]+)/(?P.*)' => - 'PhameResourceController', + ), ); } diff --git a/src/applications/phortune/application/PhabricatorPhortuneApplication.php b/src/applications/phortune/application/PhabricatorPhortuneApplication.php index 79b246770e..25680ba6c5 100644 --- a/src/applications/phortune/application/PhabricatorPhortuneApplication.php +++ b/src/applications/phortune/application/PhabricatorPhortuneApplication.php @@ -101,11 +101,8 @@ final class PhabricatorPhortuneApplication extends PhabricatorApplication { 'product/' => array( '' => 'PhortuneProductListController', 'view/(?P\d+)/' => 'PhortuneProductViewController', - 'edit/(?:(?P\d+)/)?' => 'PhortuneProductEditController', ), 'provider/' => array( - 'edit/(?:(?P\d+)/)?' => 'PhortuneProviderEditController', - 'disable/(?P\d+)/' => 'PhortuneProviderDisableController', '(?P\d+)/(?P[^/]+)/' => 'PhortuneProviderActionController', ), diff --git a/src/applications/search/application/PhabricatorSearchApplication.php b/src/applications/search/application/PhabricatorSearchApplication.php index 7547506258..be229b1aec 100644 --- a/src/applications/search/application/PhabricatorSearchApplication.php +++ b/src/applications/search/application/PhabricatorSearchApplication.php @@ -30,7 +30,6 @@ final class PhabricatorSearchApplication extends PhabricatorApplication { return array( '/search/' => array( '(?:query/(?P[^/]+)/)?' => 'PhabricatorSearchController', - 'index/(?P[^/]+)/' => 'PhabricatorSearchIndexController', 'hovercard/' => 'PhabricatorSearchHovercardController', 'handle/(?P[^/]+)/'