/** * Return an error page, optionally with data/message * * @param int HTTP status code * @param array|string Data or message */ public static function error($status = 500, $data = array()) { is_string($data) && ($data = array('message' => $data)); $data['error'] = true; if (Request::ajax() || Request::accepts('application/json')) { return parent::json($data, $status); } if ($status == 404) { return parent::error($status, $data); } return \Event::first('response.error', [$status, $data]); }
/** * Ensures the setAccept header sets the accept variable * * @return void * * @test */ public function setAcceptSetsTheAcceptVariable() { $accept = uniqid() . ',' . uniqid() . ',' . uniqid(); $acceptParts = explode(',', $accept); $request = new \Request($this->config, []); $request->setAccept($accept); $this->assertEquals($acceptParts, $request->accept); foreach ($acceptParts as $thing) { $this->assertTrue($request->accepts($thing)); } }