Example #1
0
 /**
  * @inheritdoc
  */
 public function handleException(\Exception $exception)
 {
     if (!$exception instanceof ApiException) {
         $exception = new ApiException($exception->getMessage(), $exception->getCode());
     }
     //Let the end user known the exception message
     $apiResponse = Response::create($exception->getFormatted(new JsonFormat()));
     $apiResponse->headers->set("Content-Type", "application/json");
     return $apiResponse;
 }
Example #2
0
 public function testHeaders()
 {
     $request = Request::createFromGlobals();
     $kernel = $this->getKernel(Response::create('abc'));
     $resp = $kernel->handle($request, Cubex::MASTER_REQUEST, false);
     if ($resp instanceof Response) {
         $resp->setCubexHeaders();
     }
     $this->assertTrue($resp->headers->has('X-Execution-Time'));
     $this->assertTrue($resp->headers->has('X-Call-Time'));
 }
Example #3
0
 public function testGetLayoutSection()
 {
     $layout = new Layout(new TestLayoutController());
     $view = new TestView();
     $layout->insert('content', $view);
     $response = new TestResponse(Response::create($layout));
     $test = new MockCubexTestCase();
     $test->setLastResponse($response);
     $this->assertSame($view, $test->getLayoutSection());
 }