Exemplo n.º 1
0
 /**
  * @covers \Colonel\HttpKernel::handle
  * @covers \Colonel\HttpKernel::run
  */
 public function test_handle_is_successful_without_a_service_provider()
 {
     $app = new HttpKernel(['debug' => false, 'services' => ['di' => []], 'route_strategy' => UriRequestStrategy::class, 'routes' => ['test_group' => ['test_route' => ['pattern' => '/', 'controller' => function () {
         return Response::create('<h1>Hello World</h1>', 200);
     }, 'method' => 'GET']]], 'service_providers' => []]);
     $_SERVER['REQUEST_URI'] = '/';
     $response = $app->handle(Request::createFromGlobals(), HttpKernel::MASTER_REQUEST);
     $this->assertEquals('<h1>Hello World</h1>', $response->getContent());
 }
Exemplo n.º 2
0
 /**
  * @covers \Colonel\HttpKernel::handle
  * @covers \Colonel\HttpKernel::run
  */
 public function test_handle_is_successful()
 {
     $app = new HttpKernel(['debug' => false, 'services' => ['di' => []], 'route_strategy' => UriRequestStrategy::class, 'routes' => ['test_group' => ['test_route' => ['pattern' => '/', 'controller' => function () {
         return Response::create('<h1>It works!</h1>', 200);
     }, 'method' => 'GET']]]]);
     $request = Request::createFromGlobals();
     $response = $app->handle($request, 1, true);
     $this->assertEquals('<h1>It works!</h1>', $response->getContent());
 }
Exemplo n.º 3
0
 /** @covers UriRequestStrategy::dispatch */
 public function test_UriRequestStrategy_displays_correct_data()
 {
     $_SERVER['REQUEST_URI'] = '/users/scooby/address/mystery-van';
     $app = new HttpKernel(['debug' => false, 'services' => ['di' => []], 'route_strategy' => UriRequestStrategy::class, 'routes' => ['test_group' => ['test_route' => ['pattern' => '/users/{name}/address/{address}', 'controller' => function ($name, $address) {
         return Response::create(json_encode([$name, $address]), 200);
     }, 'method' => 'GET']]]]);
     $request = Request::createFromGlobals();
     $response = $app->handle($request);
     $this->assertEquals('["scooby","mystery-van"]', $response->getContent());
 }