コード例 #1
0
ファイル: RequestMatcherTest.php プロジェクト: lucidphp/mux
 /** @test */
 public function itShouldMapDefaultValues()
 {
     $matcher = new Matcher();
     $routes = new Routes();
     $routes->add('user', new Route('/user/{id?}', 'getUserAction', ['GET'], null, ['id' => 12]));
     $request = $this->mockRequest();
     $request->method('getMethod')->willReturn('GET');
     $request->method('getPath')->willReturn('/user');
     $request->method('getScheme')->willReturn('http');
     $result = $matcher->matchRequest($request, $routes);
     $vars = $result->getVars();
     $this->assertArrayHasKey('id', $vars);
     $this->assertSame(12, $vars['id']);
 }
コード例 #2
0
ファイル: RoutesTest.php プロジェクト: lucidphp/mux
 /** @test */
 public function itShouldReturnEmptyCollection()
 {
     $routes = new Routes(['foo' => $this->mockRoute(['GET'], ['HTTPS'])]);
     $this->assertEmpty($routes->findByMethod('post')->all());
     $this->assertEmpty($routes->findByScheme('http')->all());
 }