Ejemplo n.º 1
0
 public function testLayoutDoesntWorkForJsonResponse()
 {
     LayoutModule::setLayoutClassName("Rhubarb\\Crown\\Tests\\Layout\\TestLayout");
     $model = new \stdClass();
     $model->Field = "Value";
     $response = new JsonResponse();
     $response->setContent($model);
     $layoutFilter = new LayoutFilter();
     $layoutFilter->processResponse($response);
     $this->assertEquals("Value", $response->getContent()->Field);
 }
Ejemplo n.º 2
0
 public function testResponseCanCodeNonModels()
 {
     $response = new JsonResponse();
     $test = ["abc", "123"];
     $response->setContent($test);
     ob_start();
     $response->send();
     $buffer = ob_get_clean();
     $this->assertEquals('["abc","123"]', $buffer);
     $response = new JsonResponse();
     $test = new \stdClass();
     $test->abc = "123";
     $response->setContent($test);
     ob_start();
     $response->send();
     $buffer = ob_get_clean();
     $this->assertEquals('{"abc":"123"}', $buffer);
 }