public function testCanHintToApiProblemToRenderStackTrace()
 {
     $exception = new \Exception('exception message', 500);
     $apiProblem = new ApiProblem(500, $exception);
     $model = new ApiProblemModel();
     $model->setApiProblem($apiProblem);
     $this->renderer->setDisplayExceptions(true);
     $test = $this->renderer->render($model);
     $test = json_decode($test, true);
     $this->assertArrayHasKey('trace', $test);
     $this->assertInternalType('array', $test['trace']);
     $this->assertGreaterThanOrEqual(1, count($test['trace']));
 }
示例#2
0
 /**
  * Determine the response content-type to return based on the view model.
  *
  * @param ApiProblemModel|HalJsonModel|\Zend\View\Model\ModelInterface $model
  * @return string The content-type to use.
  */
 private function getContentTypeFromModel($model)
 {
     if ($model instanceof ApiProblemModel) {
         return 'application/problem+json';
     }
     if ($model instanceof HalJsonModel && ($model->isCollection() || $model->isEntity())) {
         return 'application/hal+json';
     }
     return $this->contentType;
 }