示例#1
0
 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());
 }
示例#2
0
 /**
  * @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');
 }