diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index 7c05af3a390e..6b53689d04e2 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -80,7 +80,7 @@ public function testUseDefaultValueTypeIntAndFloatValues(): void $dotenv->load(); $config = new SimpleConfig(); - $this->assertSame(0.0, $config->float); + $this->assertEqualsWithDelta(0.0, $config->float, PHP_FLOAT_EPSILON); $this->assertSame(999, $config->int); } diff --git a/tests/system/Database/Live/SelectTest.php b/tests/system/Database/Live/SelectTest.php index c32f5e116828..cd4b1a5f93d1 100644 --- a/tests/system/Database/Live/SelectTest.php +++ b/tests/system/Database/Live/SelectTest.php @@ -86,14 +86,14 @@ public function testSelectAvg(): void { $result = $this->db->table('job')->selectAvg('id')->get()->getRow(); - $this->assertSame(2.5, (float) $result->id); + $this->assertEqualsWithDelta(2.5, (float) $result->id, PHP_FLOAT_EPSILON); } public function testSelectAvgWithAlias(): void { $result = $this->db->table('job')->selectAvg('id', 'xam')->get()->getRow(); - $this->assertSame(2.5, (float) $result->xam); + $this->assertEqualsWithDelta(2.5, (float) $result->xam, PHP_FLOAT_EPSILON); } public function testSelectSum(): void diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index dadea32b5680..b02756c22406 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -373,12 +373,12 @@ public function testCastFloat(): void $entity->second = 3; $this->assertIsFloat($entity->second); - $this->assertSame(3.0, $entity->second); + $this->assertEqualsWithDelta(3.0, $entity->second, PHP_FLOAT_EPSILON); $entity->second = '3.6'; $this->assertIsFloat($entity->second); - $this->assertSame(3.6, $entity->second); + $this->assertEqualsWithDelta(3.6, $entity->second, PHP_FLOAT_EPSILON); } public function testCastDouble(): void @@ -388,12 +388,12 @@ public function testCastDouble(): void $entity->third = 3; $this->assertIsFloat($entity->third); - $this->assertSame(3.0, $entity->third); + $this->assertEqualsWithDelta(3.0, $entity->third, PHP_FLOAT_EPSILON); $entity->third = '3.6'; $this->assertIsFloat($entity->third); - $this->assertSame(3.6, $entity->third); + $this->assertEqualsWithDelta(3.6, $entity->third, PHP_FLOAT_EPSILON); } public function testCastString(): void diff --git a/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php b/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php index a0a9ffcda4c6..d8e96424dae5 100644 --- a/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php +++ b/tests/system/HTTP/CURLRequestDoNotShareOptionsTest.php @@ -267,14 +267,14 @@ public function testHeaderContentLengthNotSharedBetweenClients(): void public function testOptionsDelay(): void { $request = $this->getRequest(); - $this->assertSame(0.0, $request->getDelay()); + $this->assertEqualsWithDelta(0.0, $request->getDelay(), PHP_FLOAT_EPSILON); $options = [ 'delay' => 2000, 'headers' => ['fruit' => 'apple'], ]; $request = $this->getRequest($options); - $this->assertSame(2.0, $request->getDelay()); + $this->assertEqualsWithDelta(2.0, $request->getDelay(), PHP_FLOAT_EPSILON); } public function testPatchSetsCorrectMethod(): void @@ -356,10 +356,10 @@ public function testRequestSetsBasicCurlOptions(): void $this->assertTrue($options[CURLOPT_FRESH_CONNECT]); $this->assertArrayHasKey(CURLOPT_TIMEOUT_MS, $options); - $this->assertSame(0.0, $options[CURLOPT_TIMEOUT_MS]); + $this->assertEqualsWithDelta(0.0, $options[CURLOPT_TIMEOUT_MS], PHP_FLOAT_EPSILON); $this->assertArrayHasKey(CURLOPT_CONNECTTIMEOUT_MS, $options); - $this->assertSame(150000.0, $options[CURLOPT_CONNECTTIMEOUT_MS]); + $this->assertEqualsWithDelta(150000.0, $options[CURLOPT_CONNECTTIMEOUT_MS], PHP_FLOAT_EPSILON); } public function testAuthBasicOption(): void @@ -734,7 +734,7 @@ public function testSendWithDelay(): void $request->get('products'); // we still need to check the code coverage to make sure this was done - $this->assertSame(0.1, $request->getDelay()); + $this->assertEqualsWithDelta(0.1, $request->getDelay(), PHP_FLOAT_EPSILON); } public function testSendContinued(): void diff --git a/tests/system/HTTP/CURLRequestTest.php b/tests/system/HTTP/CURLRequestTest.php index f7a1ce6fe9e7..186284da6ba6 100644 --- a/tests/system/HTTP/CURLRequestTest.php +++ b/tests/system/HTTP/CURLRequestTest.php @@ -250,14 +250,14 @@ public function testHeaderContentLengthNotSharedBetweenClients(): void public function testOptionsDelay(): void { $request = $this->getRequest(); - $this->assertSame(0.0, $request->getDelay()); + $this->assertEqualsWithDelta(0.0, $request->getDelay(), PHP_FLOAT_EPSILON); $options = [ 'delay' => 2000, 'headers' => ['fruit' => 'apple'], ]; $request = $this->getRequest($options); - $this->assertSame(2.0, $request->getDelay()); + $this->assertEqualsWithDelta(2.0, $request->getDelay(), PHP_FLOAT_EPSILON); } public function testPatchSetsCorrectMethod(): void @@ -339,10 +339,10 @@ public function testRequestSetsBasicCurlOptions(): void $this->assertTrue($options[CURLOPT_FRESH_CONNECT]); $this->assertArrayHasKey(CURLOPT_TIMEOUT_MS, $options); - $this->assertSame(0.0, $options[CURLOPT_TIMEOUT_MS]); + $this->assertEqualsWithDelta(0.0, $options[CURLOPT_TIMEOUT_MS], PHP_FLOAT_EPSILON); $this->assertArrayHasKey(CURLOPT_CONNECTTIMEOUT_MS, $options); - $this->assertSame(150000.0, $options[CURLOPT_CONNECTTIMEOUT_MS]); + $this->assertEqualsWithDelta(150000.0, $options[CURLOPT_CONNECTTIMEOUT_MS], PHP_FLOAT_EPSILON); } public function testAuthBasicOption(): void @@ -717,7 +717,7 @@ public function testSendWithDelay(): void $request->get('products'); // we still need to check the code coverage to make sure this was done - $this->assertSame(0.1, $request->getDelay()); + $this->assertEqualsWithDelta(0.1, $request->getDelay(), PHP_FLOAT_EPSILON); } public function testSendContinued(): void diff --git a/tests/system/HTTP/IncomingRequestTest.php b/tests/system/HTTP/IncomingRequestTest.php index 3855a4b85c94..98fef5322df2 100644 --- a/tests/system/HTTP/IncomingRequestTest.php +++ b/tests/system/HTTP/IncomingRequestTest.php @@ -348,7 +348,7 @@ public function testCanGetAVariableFromJson(): void $this->assertSame('buzz', $jsonVar->fizz); $this->assertSame('buzz', $request->getJsonVar('baz.fizz')); $this->assertSame(123, $request->getJsonVar('int')); - $this->assertSame(3.14, $request->getJsonVar('float')); + $this->assertEqualsWithDelta(3.14, $request->getJsonVar('float'), PHP_FLOAT_EPSILON); $this->assertTrue($request->getJsonVar('true')); $this->assertFalse($request->getJsonVar('false')); $this->assertNull($request->getJsonVar('null')); @@ -379,7 +379,7 @@ public function testGetJsonVarAsArray(): void $this->assertSame('buzz', $jsonVar['fizz']); $this->assertSame('bar', $jsonVar['foo']); $this->assertSame(123, $jsonVar['int']); - $this->assertSame(3.14, $jsonVar['float']); + $this->assertEqualsWithDelta(3.14, $jsonVar['float'], PHP_FLOAT_EPSILON); $this->assertTrue($jsonVar['true']); $this->assertFalse($jsonVar['false']); $this->assertNull($jsonVar['null']); diff --git a/tests/system/Session/Handlers/Database/RedisHandlerTest.php b/tests/system/Session/Handlers/Database/RedisHandlerTest.php index 94d17461d243..d5e8b61e7700 100644 --- a/tests/system/Session/Handlers/Database/RedisHandlerTest.php +++ b/tests/system/Session/Handlers/Database/RedisHandlerTest.php @@ -93,7 +93,7 @@ public function testSavePathTimeoutFloat(): void $savePath = $this->getPrivateProperty($handler, 'savePath'); - $this->assertSame(2.5, $savePath['timeout']); + $this->assertEqualsWithDelta(2.5, $savePath['timeout'], PHP_FLOAT_EPSILON); } public function testSavePathTimeoutInt(): void @@ -104,7 +104,7 @@ public function testSavePathTimeoutInt(): void $savePath = $this->getPrivateProperty($handler, 'savePath'); - $this->assertSame(10.0, $savePath['timeout']); + $this->assertEqualsWithDelta(10.0, $savePath['timeout'], PHP_FLOAT_EPSILON); } public function testOpen(): void diff --git a/tests/system/Throttle/ThrottleTest.php b/tests/system/Throttle/ThrottleTest.php index 16d58ac506d4..1cd0abf99407 100644 --- a/tests/system/Throttle/ThrottleTest.php +++ b/tests/system/Throttle/ThrottleTest.php @@ -185,7 +185,7 @@ public function testFlooding(): void $throttler = $throttler->setTestTime($time + 10); $this->assertTrue($throttler->check('127.0.0.1', $rate, MINUTE, 0)); - $this->assertSame(10.0, round($this->cache->get('throttler_127.0.0.1'))); + $this->assertEqualsWithDelta(10.0, round($this->cache->get('throttler_127.0.0.1')), PHP_FLOAT_EPSILON); } /**