Laravel version update
Laravel version update
This commit is contained in:
@@ -11,10 +11,20 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Tests;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
class JsonResponseTest extends \PHPUnit_Framework_TestCase
|
||||
class JsonResponseTest extends TestCase
|
||||
{
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (!\defined('HHVM_VERSION')) {
|
||||
$this->iniSet('serialize_precision', 14);
|
||||
}
|
||||
}
|
||||
|
||||
public function testConstructorEmptyCreatesJsonObject()
|
||||
{
|
||||
$response = new JsonResponse();
|
||||
@@ -75,6 +85,19 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('application/vnd.acme.blog-v1+json', $response->headers->get('Content-Type'));
|
||||
}
|
||||
|
||||
public function testSetJson()
|
||||
{
|
||||
$response = new JsonResponse('1', 200, array(), true);
|
||||
$this->assertEquals('1', $response->getContent());
|
||||
|
||||
$response = new JsonResponse('[1]', 200, array(), true);
|
||||
$this->assertEquals('[1]', $response->getContent());
|
||||
|
||||
$response = new JsonResponse(null, 200, array());
|
||||
$response->setJson('true');
|
||||
$this->assertEquals('true', $response->getContent());
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$response = JsonResponse::create(array('foo' => 'bar'), 204);
|
||||
@@ -185,6 +208,12 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('{"0":{"0":1,"1":2,"2":3}}', $response->getContent());
|
||||
}
|
||||
|
||||
public function testItAcceptsJsonAsString()
|
||||
{
|
||||
$response = JsonResponse::fromJsonString('{"foo":"bar"}');
|
||||
$this->assertSame('{"foo":"bar"}', $response->getContent());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \InvalidArgumentException
|
||||
*/
|
||||
@@ -208,13 +237,25 @@ class JsonResponseTest extends \PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testSetContentJsonSerializeError()
|
||||
{
|
||||
if (!interface_exists('JsonSerializable', false)) {
|
||||
$this->markTestSkipped('JsonSerializable is required.');
|
||||
}
|
||||
|
||||
$serializable = new JsonSerializableObject();
|
||||
|
||||
JsonResponse::create($serializable);
|
||||
}
|
||||
|
||||
public function testSetComplexCallback()
|
||||
{
|
||||
$response = JsonResponse::create(array('foo' => 'bar'));
|
||||
$response->setCallback('ಠ_ಠ["foo"].bar[0]');
|
||||
|
||||
$this->assertEquals('/**/ಠ_ಠ["foo"].bar[0]({"foo":"bar"});', $response->getContent());
|
||||
}
|
||||
}
|
||||
|
||||
if (interface_exists('JsonSerializable')) {
|
||||
if (interface_exists('JsonSerializable', false)) {
|
||||
class JsonSerializableObject implements \JsonSerializable
|
||||
{
|
||||
public function jsonSerialize()
|
||||
|
Reference in New Issue
Block a user