Use AsserEquals for floating-point values
Use AssertEquals for these two specific case will do a better job, since it'll convert both '0.1' and result of `getContent()` into PHP's internal representation of floating-point and compares them and it should be fine. Using `AssertSame` for this tests brings floating-point serialization into consideration which of course will be php.ini specific. In order not missing the type assertion point that `AssertSame` does, we also perform `assertInternalType('string'...` Sponsored-by: Platform.sh
This commit is contained in:
parent
bb9a67df3b
commit
0cef5f3ec9
@ -52,7 +52,8 @@ class JsonResponseTest extends TestCase
|
|||||||
$this->assertSame('0', $response->getContent());
|
$this->assertSame('0', $response->getContent());
|
||||||
|
|
||||||
$response = new JsonResponse(0.1);
|
$response = new JsonResponse(0.1);
|
||||||
$this->assertSame('0.1', $response->getContent());
|
$this->assertEquals('0.1', $response->getContent());
|
||||||
|
$this->assertInternalType('string', $response->getContent());
|
||||||
|
|
||||||
$response = new JsonResponse(true);
|
$response = new JsonResponse(true);
|
||||||
$this->assertSame('true', $response->getContent());
|
$this->assertSame('true', $response->getContent());
|
||||||
@ -140,7 +141,8 @@ class JsonResponseTest extends TestCase
|
|||||||
|
|
||||||
$response = JsonResponse::create(0.1);
|
$response = JsonResponse::create(0.1);
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||||
$this->assertSame('0.1', $response->getContent());
|
$this->assertEquals('0.1', $response->getContent());
|
||||||
|
$this->assertInternalType('string', $response->getContent());
|
||||||
|
|
||||||
$response = JsonResponse::create(true);
|
$response = JsonResponse::create(true);
|
||||||
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
$this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);
|
||||||
|
Reference in New Issue
Block a user