/** * @dataProvider routeProvider * @param string $routeDefinition * @param array $arguments * @param array|null $params */ public function testMatching($routeDefinition, array $arguments = array(), array $params = null) { array_unshift($arguments, 'scriptname.php'); $request = new ConsoleRequest($arguments); $route = new Simple($routeDefinition); $match = $route->match($request); if ($params === null) { $this->assertNull($match, "The route must not match"); } else { $this->assertInstanceOf('Zend\\Mvc\\Router\\Console\\RouteMatch', $match, "The route matches"); foreach ($params as $key => $value) { $this->assertEquals($value, $match->getParam($key), $value === null ? "Param {$key} is not present" : "Param {$key} is present and is equal to {$value}"); } } }
public function testCustomRouteMatcherCanBeInjectedViaConstructor() { $arguments = array('--foo=bar'); array_unshift($arguments, 'scriptname.php'); $request = new ConsoleRequest($arguments); $routeMatcher = $this->getMock('Zend\\Console\\RouteMatcher\\RouteMatcherInterface', array('match')); $routeMatcher->expects($this->once())->method('match')->with(array('--foo=bar')); $route = new Simple($routeMatcher); $route->match($request); }
public function testCanNotMatchingWithEmtpyMandatoryParam() { $arguments = array('--foo='); array_unshift($arguments,'scriptname.php'); $request = new ConsoleRequest($arguments); $route = new Simple('--foo='); $match = $route->match($request); $this->assertEquals(null, $match); }