public function test_create() { $app = new HttpApp(); $config = new Config(); $config->set('routing', ['routes' => [['method' => 'GET', 'path' => '/foo', 'action' => 'foo']]]); $app->getConfigLoader()->addConfig($config); $app->getKernel()->addProvider(RequestHandlerProvider::class); $app->handleRequest(new HttpRequest()); /** @var IRouter $router */ $router = $app->getContainer()->get(IRouter::class); $handler = $app->getContainer()->get(IRequestHandler::class); $routes = $router->getRoutes(); $this->assertEquals(1, count($routes)); $route = $routes[0]; $this->assertEquals(['GET'], $route->getMethods()); $this->assertEquals('/foo', $route->getPath()); $this->assertEquals('foo', $route->getAction()); }
public function test_shares_its_instance_in_the_container() { $app = new HttpApp(); $this->assertTrue($app->getContainer()->get(HttpApp::class) === $app); $this->assertTrue($app->getContainer()->get(IHttpApp::class) === $app); }