public function test_invoke()
 {
     $invoker = new ArraySyntaxRouteInvoker();
     $container = new Container();
     $item = new FooItem();
     $route = new Route([HttpRequestMethod::GET], 'foo', [FooItem::class, 'test']);
     $route->setParameter('bar', $item);
     $this->assertTrue($invoker->invoke($route, $container) === $item);
 }
 public function test_invoke()
 {
     $invoker = new CallableRouteInvoker();
     $item = new FooItem();
     $route = new Route([HttpRequestMethod::GET], 'foo', function (FooItem $foo, FooItem $item) {
         return $item;
     });
     $route->setParameter('item', $item);
     $this->assertTrue($invoker->invoke($route, new Container()) === $item);
 }
コード例 #3
0
ファイル: RouteTest.php プロジェクト: weew/router
 public function test_get_and_set_parameters()
 {
     $route = new Route([HttpRequestMethod::GET], '/', 'foo');
     $route->setParameters(['foo' => 'bar', 'baz' => null]);
     $this->assertEquals('bar', $route->getParameter('foo'));
     $this->assertEquals('bar', $route->getParameter('baz', 'bar'));
     $this->assertEquals('swag', $route->getParameter('yolo', 'swag'));
     $route->setParameter('yolo', 'swag');
     $this->assertEquals('swag', $route->getParameter('yolo'));
 }