示例#1
0
 /**
  * @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}");
         }
     }
 }
示例#2
0
 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);
 }
示例#3
0
 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);
 }