public function testViewCreateMethod() { $data = ['foo' => 'Cygnite!']; $content = View::create("fixtures.hello", $data); $this->assertEquals('Hello Cygnite!', Response::make($content)->getContent()); $data = ['foo' => 'Foo Bar!']; $composeContent = View::compose("fixtures.hello", $data); $this->assertEquals('Hello Foo Bar!', Response::make($composeContent)->getContent()); }
/** * @param null $content * @param array $headers * @param bool $prettyPrint */ public function __construct($content = null, $headers = [], $prettyPrint = false) { if (null === $content) { $content = new \ArrayObject(); } if (is_array($content) || is_object($content)) { $content = $this->jsonEncode($content, $prettyPrint); } parent::__construct($content, 200, $headers); $this->setContentType('application/json'); }