diff options
author | Bernhard Posselt <Raydiation@users.noreply.github.com> | 2014-09-09 23:40:46 +0200 |
---|---|---|
committer | Bernhard Posselt <Raydiation@users.noreply.github.com> | 2014-09-09 23:40:46 +0200 |
commit | ba698a4942ba3db13069c73aba5eb610c74604f9 (patch) | |
tree | 7564831f1272b402dbcc3d9f335d6b2c4d2950ca /tests | |
parent | c3d90b96c8ec4bcf96e28c6ccdb194494888cc61 (diff) | |
parent | cb5416b798a9fde6d4826ad82b1f846b88a1ffcd (diff) | |
download | nextcloud-server-ba698a4942ba3db13069c73aba5eb610c74604f9.tar.gz nextcloud-server-ba698a4942ba3db13069c73aba5eb610c74604f9.zip |
Merge pull request #10972 from ppaysant/routes-defaults
Allow default values for route parameters.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/appframework/routing/RoutingTest.php | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/tests/lib/appframework/routing/RoutingTest.php b/tests/lib/appframework/routing/RoutingTest.php index 7cd07db6ce1..a1d9a51a3c8 100644 --- a/tests/lib/appframework/routing/RoutingTest.php +++ b/tests/lib/appframework/routing/RoutingTest.php @@ -45,6 +45,15 @@ class RoutingTest extends \PHPUnit_Framework_TestCase $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', array('something')); } + public function testSimpleRouteWithDefaults() + { + $routes = array('routes' => array( + array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', array(), 'defaults' => array('param' => 'foobar')) + )); + + $this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', array(), array('param' => 'foobar')); + } + /** * @expectedException \UnexpectedValueException @@ -95,10 +104,10 @@ class RoutingTest extends \PHPUnit_Framework_TestCase * @param string $controllerName * @param string $actionName */ - private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName, array $requirements=array()) + private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName, array $requirements=array(), array $defaults=array()) { // route mocks - $route = $this->mockRoute($verb, $controllerName, $actionName, $requirements); + $route = $this->mockRoute($verb, $controllerName, $actionName, $requirements, $defaults); // router mock $router = $this->getMock("\OC\Route\Router", array('create')); @@ -181,10 +190,10 @@ class RoutingTest extends \PHPUnit_Framework_TestCase * @param string $actionName * @return \PHPUnit_Framework_MockObject_MockObject */ - private function mockRoute($verb, $controllerName, $actionName, array $requirements=array()) + private function mockRoute($verb, $controllerName, $actionName, array $requirements=array(), array $defaults=array()) { $container = new DIContainer('app1'); - $route = $this->getMock("\OC\Route\Route", array('method', 'action', 'requirements'), array(), '', false); + $route = $this->getMock("\OC\Route\Route", array('method', 'action', 'requirements', 'defaults'), array(), '', false); $route ->expects($this->exactly(1)) ->method('method') @@ -204,6 +213,15 @@ class RoutingTest extends \PHPUnit_Framework_TestCase ->with($this->equalTo($requirements)) ->will($this->returnValue($route)); } + + if (count($defaults) > 0) { + $route + ->expects($this->exactly(1)) + ->method('defaults') + ->with($this->equalTo($defaults)) + ->will($this->returnValue($route)); + } + return $route; } |