$routeName = $routeNamePrefix . $this->appName . '.' . $controller . '.' . $action . $postfix;
$router = $this->router->create($routeName, $url)
- ->method($verb)
- ->setDefault('caller', [$this->appName, $controllerName, $actionName]);
+ ->method($verb);
// optionally register requirements for route. This is used to
// tell the route parser how url parameters should be matched
// optionally register defaults for route. This is used to
// tell the route parser how url parameters should be default valued
+ $defaults = [];
if (array_key_exists('defaults', $route)) {
- $router->defaults($route['defaults']);
+ $defaults = $route['defaults'];
}
+
+ $defaults['caller'] = [$this->appName, $controllerName, $actionName];
+ $router->defaults($defaults);
}
/**
$routeName = $routeNamePrefix . $this->appName . '.' . strtolower($resource) . '.' . strtolower($method);
- $this->router->create($routeName, $url)
- ->method($verb)
- ->setDefault('caller', [$this->appName, $controllerName, $actionName]);
+ $route = $this->router->create($routeName, $url)
+ ->method($verb);
+
+ $route->defaults(['caller' => [$this->appName, $controllerName, $actionName]]);
}
}
}
array $defaults=[]
) {
$route = $this->getMockBuilder(Route::class)
- ->onlyMethods(['method', 'setDefault', 'requirements', 'defaults'])
+ ->onlyMethods(['method', 'requirements', 'defaults'])
->disableOriginalConstructor()
->getMock();
$route
->with($this->equalTo($verb))
->willReturn($route);
- $route
- ->expects($this->once())
- ->method('setDefault')
- ->with('caller', ['app1', $controllerName, $actionName])
- ->willReturn($route);
-
if (count($requirements) > 0) {
$route
->expects($this->once())
->willReturn($route);
}
- if (count($defaults) > 0) {
- $route
- ->expects($this->once())
- ->method('defaults')
- ->with($this->equalTo($defaults))
- ->willReturn($route);
- }
+ $route->expects($this->once())
+ ->method('defaults')
+ ->with($this->callback(function (array $def) use ($defaults, $controllerName, $actionName) {
+ $defaults['caller'] = ['app1', $controllerName, $actionName];
+
+ $this->assertEquals($defaults, $def);
+ return true;
+ }))
+ ->willReturn($route);
return $route;
}