From 0cef5f3ec9b7c9ab47842c7b6f9f2b8cf77cdd8a Mon Sep 17 00:00:00 2001 From: mmokhi Date: Fri, 24 May 2019 19:14:44 +0200 Subject: [PATCH] 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 --- .../Component/HttpFoundation/Tests/JsonResponseTest.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php index 5425896dfa3b..ef0346cbe6da 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/JsonResponseTest.php @@ -52,7 +52,8 @@ public function testConstructorWithSimpleTypes() $this->assertSame('0', $response->getContent()); $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); $this->assertSame('true', $response->getContent()); @@ -140,7 +141,8 @@ public function testStaticCreateWithSimpleTypes() $response = JsonResponse::create(0.1); $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); $this->assertInstanceOf('Symfony\Component\HttpFoundation\JsonResponse', $response);