public function testMatch()
 {
     $router1Result = new MatchedRoute(new \stdClass(), 'index', []);
     $router2Result = new MatchedRoute(new \stdClass(), 'index', []);
     $router3Result = new MatchedRoute(new \stdClass(), 'index', []);
     $router1 = $this->createRouterMock('/foo/show/(\\d+)', $router1Result);
     $router2 = $this->createRouterMock('/foo/page/p(\\d+)', $router2Result);
     $router3 = $this->createRouterMock('/foo/', $router3Result);
     $router = new OptimizedRouterCollection([$router1, $router2, $router3]);
     $request = Request::create('/foo/show/123');
     $this->assertSame($router1Result, $router->match($request));
     $request = Request::create('/foo/page/p123');
     $this->assertSame($router2Result, $router->match($request));
     $request = Request::create('/foo/');
     $this->assertSame($router3Result, $router->match($request));
     $request = Request::create('/bar/');
     $this->assertNull($router->match($request));
 }
Esempio n. 2
0
 /**
  * @iterations 1000
  */
 public function optimizedRouterCollectionWithConstructor()
 {
     $optimizedRouterCollection = new OptimizedRouterCollection($this->routers);
     $match = $optimizedRouterCollection->match($this->request);
     assert($match !== null);
 }