diff options
author | Clara Andrew-Wani <candrewwani@gmail.com> | 2020-03-23 17:53:02 -0400 |
---|---|---|
committer | Clara Andrew-Wani <candrewwani@gmail.com> | 2020-03-24 11:29:39 -0400 |
commit | dffacb0057799f9d5d273962831907676e8cdbff (patch) | |
tree | 508e881aa99f97ad6b4049a01f86804ce39a90a9 /tests/phpunit/structure/RestStructureTest.php | |
parent | a67762cab94056f3a6e7bf359fc7f2c8dfe6e2d1 (diff) | |
download | mediawikicore-dffacb0057799f9d5d273962831907676e8cdbff.tar.gz mediawikicore-dffacb0057799f9d5d273962831907676e8cdbff.zip |
Update RestStructureTest to include HTTP Method
Change-Id: If05ba2884ba8e256c7fee45164eee1fc2d014589
Diffstat (limited to 'tests/phpunit/structure/RestStructureTest.php')
-rw-r--r-- | tests/phpunit/structure/RestStructureTest.php | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/tests/phpunit/structure/RestStructureTest.php b/tests/phpunit/structure/RestStructureTest.php index b60de3e5558a..0201317ed777 100644 --- a/tests/phpunit/structure/RestStructureTest.php +++ b/tests/phpunit/structure/RestStructureTest.php @@ -80,10 +80,12 @@ class RestStructureTest extends MediaWikiTestCase { public static function providePathParameters() : Iterator { $router = TestingAccessWrapper::newFromObject( self::getRouter() ); - $request = new RequestData(); foreach ( $router->getAllRoutes() as $spec ) { - yield "Handler {$spec['path']}" => [ $spec ]; + $method = $spec['method'] ?? 'GET'; + $method = implode( ",", (array)$method ); + + yield "Handler {$method} {$spec['path']}" => [ $spec ]; } } @@ -151,7 +153,28 @@ class RestStructureTest extends MediaWikiTestCase { $handler = $router->createHandler( $request, $spec ); $params = $handler->getParamSettings(); foreach ( $params as $param => $settings ) { - yield "Handler {$spec['path']}, parameter $param" => [ $spec, $param, $settings ]; + $method = $spec['method'] ?? 'GET'; + $method = implode( ",", (array)$method ); + + yield "Handler {$method} {$spec['path']}, parameter $param" => [ $spec, $param, $settings ]; + } + } + } + + public function testRoutePathAndMethodForDuplicates() { + $router = TestingAccessWrapper::newFromObject( self::getRouter() ); + $routes = []; + + foreach ( $router->getAllRoutes() as $spec ) { + $method = $spec['method'] ?? 'GET'; + $method = (array)$method; + + foreach ( $method as $m ) { + $key = "{$m} {$spec['path']}"; + + $this->assertFalse( array_key_exists( $key, $routes ), "{$key} already exists in routes" ); + + $routes[$key] = true; } } } |