Ejemplo n.º 1
0
 public function test_has_container_aware_invokers()
 {
     $container = new Container();
     $router = new Router($container);
     $this->assertTrue($router->getCallableInvoker() instanceof CallableInvoker);
     $this->assertTrue($router->getRoutesMatcher()->getFiltersMatcher()->getFilterInvoker() instanceof FilterInvoker);
     $this->assertTrue($router->getRoutesMatcher()->getParameterResolver()->getParameterResolverInvoker() instanceof ParameterResolverInvoker);
 }
 public function test_resolves_entities_properly()
 {
     $router = new Router(new Container());
     $resolver = new EntitiesResolver($router);
     $resolver->resolve('fake', FakeRepository::class);
     $router->get('{fake}', function () {
     });
     $route = $router->match(HttpRequestMethod::GET, new Url('foo'));
     $this->assertTrue($route instanceof IRoute);
     $entity = $route->getParameter('fake');
     $this->assertTrue($entity instanceof FakeEntity);
     /** @var FakeEntity $entity */
     $this->assertEquals('foo', $entity->id);
 }