remove callback from constructor and create method

This commit is contained in:
Toni Uebernickel 2012-03-21 22:40:19 +01:00
parent 601b87ca01
commit 4a43453db8
2 changed files with 3 additions and 15 deletions

View File

@ -27,24 +27,20 @@ class JsonResponse extends Response
* @param mixed $data The response data
* @param integer $status The response status code
* @param array $headers An array of response headers
* @param string $callback A JSONP callback name
*/
public function __construct($data = array(), $status = 200, $headers = array(), $callback = null)
public function __construct($data = array(), $status = 200, $headers = array())
{
parent::__construct('', $status, $headers);
$this->setData($data);
$this->setCallback($callback);
}
/**
* {@inheritDoc}
*
* @param string $callback A JSONP callback name.
*/
static public function create($data = array(), $status = 200, $headers = array(), $callback = null)
static public function create($data = array(), $status = 200, $headers = array())
{
return new static($data, $status, $headers, $callback);
return new static($data, $status, $headers);
}
/**

View File

@ -89,14 +89,6 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(204, $response->getStatusCode());
}
public function testJsonp()
{
$response = new JsonResponse(array('foo' => 'bar'), 200, array(), 'callback');
$this->assertEquals('callback({"foo":"bar"});', $response->getContent());
$this->assertEquals('text/javascript', $response->headers->get('Content-Type'));
}
public function testSetCallback()
{
$response = JsonResponse::create(array('foo' => 'bar'))->setCallback('callback');