From fd05668a3e05534356ae889dba7bb26d5aa0fa73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=B6ller?= Date: Sat, 30 Dec 2017 19:46:03 +0100 Subject: [PATCH] Fix: Use more appropriate assertions --- tests/Constraints/CoerciveTest.php | 15 ++++++--------- tests/Constraints/FormatTest.php | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/Constraints/CoerciveTest.php b/tests/Constraints/CoerciveTest.php index 9a910c8a..8d58a58d 100644 --- a/tests/Constraints/CoerciveTest.php +++ b/tests/Constraints/CoerciveTest.php @@ -178,17 +178,14 @@ public function testCoerceCases($schema, $data, $startType, $endType, $endValue, // check end value $value = LooseTypeCheck::propertyGet($data, 'propertyOne'); - $this->assertTrue( - $value === $endValue, - sprintf( - "Incorrect value '%s': expected '%s'", - is_scalar($value) ? $value : gettype($value), - is_scalar($endValue) ? $endValue : gettype($endValue) - ) - ); + $this->assertSame($value, $endValue, sprintf( + "Incorrect value '%s': expected '%s'", + is_scalar($value) ? $value : gettype($value), + is_scalar($endValue) ? $endValue : gettype($endValue) + )); } else { $this->assertFalse($validator->isValid(), 'Validation succeeded, but should have failed'); - $this->assertEquals(1, count($validator->getErrors())); + $this->assertCount(1, $validator->getErrors()); } } diff --git a/tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php index b035aafe..78706c33 100644 --- a/tests/Constraints/FormatTest.php +++ b/tests/Constraints/FormatTest.php @@ -77,7 +77,7 @@ public function testInvalidFormat($string, $format) $schema->format = $format; $validator->check($string, $schema); - $this->assertEquals(1, count($validator->getErrors()), 'Expected 1 error'); + $this->assertCount(1, $validator->getErrors(), 'Expected 1 error'); } /**