예제 #1
0
 public function testCallbacksAreCalled()
 {
     $called = false;
     $this->router->resource('singular')->onMatch(function ($action) use(&$called) {
         $this->assertEquals('edit', $action);
         $called = true;
     });
     $this->router->match(new Request('GET', 'singular/edit'));
     $this->assertTrue($called);
 }
예제 #2
0
 public function testThatParameterNamesAreHandledCorrectlyRoute()
 {
     $called = false;
     $router = new Router();
     $router->get('something/{a}/{b}/{c}')->onMatch(function ($a, $b, $c, $extra) use(&$called) {
         $called = true;
         $this->assertEquals('a', $a);
         $this->assertEquals('b', $b);
         $this->assertEquals('c', $c);
         $this->assertEquals('foo', $extra);
     })->extras(['extra' => 'foo']);
     $router->put('something/{c}/{b}/{a}')->onMatch(function ($b, $c, $a, $extra) use(&$called) {
         $called = true;
         $this->assertEquals('c', $a);
         $this->assertEquals('b', $b);
         $this->assertEquals('a', $c);
         $this->assertEquals('foo', $extra);
     })->extras(['extra' => 'foo']);
     $router->match(new Request('GET', 'something/a/b/c'));
     $this->assertTrue($called);
     $called = false;
     $router->match(new Request('PUT', 'something/a/b/c'));
     $this->assertTrue($called);
 }