|
|
|
|
@ -36,6 +36,16 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
$this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testSimpleRouteWithRequirements()
|
|
|
|
|
{
|
|
|
|
|
$routes = array('routes' => array(
|
|
|
|
|
array('name' => 'folders#open', 'url' => '/folders/{folderId}/open', 'verb' => 'delete', 'requirements' => array('something'))
|
|
|
|
|
));
|
|
|
|
|
|
|
|
|
|
$this->assertSimpleRoute($routes, 'folders.open', 'DELETE', '/folders/{folderId}/open', 'FoldersController', 'open', array('something'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @expectedException \UnexpectedValueException
|
|
|
|
|
*/
|
|
|
|
|
@ -85,10 +95,10 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
* @param string $controllerName
|
|
|
|
|
* @param string $actionName
|
|
|
|
|
*/
|
|
|
|
|
private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName)
|
|
|
|
|
private function assertSimpleRoute($routes, $name, $verb, $url, $controllerName, $actionName, array $requirements=array())
|
|
|
|
|
{
|
|
|
|
|
// route mocks
|
|
|
|
|
$route = $this->mockRoute($verb, $controllerName, $actionName);
|
|
|
|
|
$route = $this->mockRoute($verb, $controllerName, $actionName, $requirements);
|
|
|
|
|
|
|
|
|
|
// router mock
|
|
|
|
|
$router = $this->getMock("\OC\Route\Router", array('create'));
|
|
|
|
|
@ -171,10 +181,10 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
* @param string $actionName
|
|
|
|
|
* @return \PHPUnit_Framework_MockObject_MockObject
|
|
|
|
|
*/
|
|
|
|
|
private function mockRoute($verb, $controllerName, $actionName)
|
|
|
|
|
private function mockRoute($verb, $controllerName, $actionName, array $requirements=array())
|
|
|
|
|
{
|
|
|
|
|
$container = new DIContainer('app1');
|
|
|
|
|
$route = $this->getMock("\OC\Route\Route", array('method', 'action'), array(), '', false);
|
|
|
|
|
$route = $this->getMock("\OC\Route\Route", array('method', 'action', 'requirements'), array(), '', false);
|
|
|
|
|
$route
|
|
|
|
|
->expects($this->exactly(1))
|
|
|
|
|
->method('method')
|
|
|
|
|
@ -186,6 +196,14 @@ class RouteConfigTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
->method('action')
|
|
|
|
|
->with($this->equalTo(new RouteActionHandler($container, $controllerName, $actionName)))
|
|
|
|
|
->will($this->returnValue($route));
|
|
|
|
|
|
|
|
|
|
if(count($requirements) > 0) {
|
|
|
|
|
$route
|
|
|
|
|
->expects($this->exactly(1))
|
|
|
|
|
->method('requirements')
|
|
|
|
|
->with($this->equalTo($requirements))
|
|
|
|
|
->will($this->returnValue($route));
|
|
|
|
|
}
|
|
|
|
|
return $route;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|