From 0a806b23a29cf46cd3fd5d3c341061027a620142 Mon Sep 17 00:00:00 2001 From: Nelson Martell Date: Wed, 16 Jan 2019 12:34:22 -0400 Subject: [PATCH] [tests] :up: Replace `assertInternalType()` assertion with specialized ones https://github.com/sebastianbergmann/phpunit/issues/3368 --- tests/Helpers/IComparableTester.php | 4 ++-- tests/Helpers/IComparerTester.php | 4 ++-- tests/Helpers/IEquatableTester.php | 2 +- tests/TestCase/TypeTest.php | 16 ++++++++-------- tests/TestCase/VersionComponentTest.php | 2 +- tests/TestCase/VersionTest.php | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/Helpers/IComparableTester.php b/tests/Helpers/IComparableTester.php index ed355bf..697364a 100644 --- a/tests/Helpers/IComparableTester.php +++ b/tests/Helpers/IComparableTester.php @@ -81,7 +81,7 @@ public function testIComparableCompareToMethod($expected, IComparable $left, $ri ); if ($expected === 0) { - $this->assertInternalType('integer', $actual, $message); + $this->assertIsInt($actual, $message); $this->assertEquals(0, $actual, $message); } else { if ($expected === null) { @@ -95,7 +95,7 @@ public function testIComparableCompareToMethod($expected, IComparable $left, $ri $major = $actual; } - $this->assertInternalType('integer', $actual, $message); + $this->assertIsInt($actual, $message); $this->assertGreaterThan($minor, $major, $message); $this->assertLessThan($major, $minor, $message); } diff --git a/tests/Helpers/IComparerTester.php b/tests/Helpers/IComparerTester.php index e86ef7a..65c3160 100644 --- a/tests/Helpers/IComparerTester.php +++ b/tests/Helpers/IComparerTester.php @@ -92,7 +92,7 @@ public function testCompareMethod($expected, $left, $right) : void ); if ($expected === 0) { - $this->assertInternalType('integer', $actual, $message); + $this->assertIsInt($actual, $message); $this->assertEquals(0, $actual, $message); } else { if ($expected === null) { @@ -106,7 +106,7 @@ public function testCompareMethod($expected, $left, $right) : void $major = $actual; } - $this->assertInternalType('integer', $actual, $message); + $this->assertIsInt($actual, $message); $this->assertGreaterThan($minor, $major, $message); $this->assertLessThan($major, $minor, $message); } diff --git a/tests/Helpers/IEquatableTester.php b/tests/Helpers/IEquatableTester.php index 012432a..15b8155 100644 --- a/tests/Helpers/IEquatableTester.php +++ b/tests/Helpers/IEquatableTester.php @@ -82,7 +82,7 @@ public function testIEquatableEqualsMethod($expected, IEquatable $left, $right) ] ); - $this->assertInternalType('boolean', $actual, $message); + $this->assertIsBool($actual, $message); if (!is_bool($expected)) { throw new InvalidArgumentException(Text::format( diff --git a/tests/TestCase/TypeTest.php b/tests/TestCase/TypeTest.php index 760fc1a..9131b61 100644 --- a/tests/TestCase/TypeTest.php +++ b/tests/TestCase/TypeTest.php @@ -214,8 +214,8 @@ public function testGetInterfaces($obj, array $interfaces) : void $reflections = $type->getInterfaces(true); $strings = $type->getInterfaces(); - $this->assertInternalType('array', $reflections); - $this->assertInternalType('array', $strings); + $this->assertIsArray($reflections); + $this->assertIsArray($strings); $this->assertCount(count($interfaces), $reflections); $this->assertCount(count($interfaces), $strings); @@ -247,8 +247,8 @@ public function testGetExplicitTraitsInClass($obj, array $traits) : void $reflections = $type->getTraits(true); $strings = $type->getTraits(); - $this->assertInternalType('array', $reflections); - $this->assertInternalType('array', $strings); + $this->assertIsArray($reflections); + $this->assertIsArray($strings); $this->assertEquals(count($strings), count($reflections), 'Not same count for strings and reflections'); $this->assertCount(count($traits), $reflections); @@ -281,8 +281,8 @@ public function testGetAllRecursiveTraitsInClass($obj, array $traits) : void $reflections = $type->getTraits(true, true); $strings = $type->getTraits(false, true); - $this->assertInternalType('array', $reflections); - $this->assertInternalType('array', $strings); + $this->assertIsArray($reflections); + $this->assertIsArray($strings); $this->assertEquals(count($strings), count($reflections), 'Not same count for strings and reflections'); $this->assertCount(count($traits), $reflections); @@ -317,7 +317,7 @@ public function testCanCheckIfTypeHasProperty($obj, string $name) : void $actual = $type->hasProperty($name); - $this->assertInternalType('bool', $actual, 'This method must return a boolean'); + $this->assertIsBool($actual, 'This method must return a boolean'); $this->assertTrue($actual); } @@ -341,7 +341,7 @@ public function testCanCheckIfTypeHasNotProperty($obj, string $name) : void $actual = $type->hasProperty($name); - $this->assertInternalType('bool', $actual, 'This method must return a boolean'); + $this->assertIsBool($actual, 'This method must return a boolean'); $this->assertFalse($actual); } diff --git a/tests/TestCase/VersionComponentTest.php b/tests/TestCase/VersionComponentTest.php index b0d9e9a..ffb9ce1 100644 --- a/tests/TestCase/VersionComponentTest.php +++ b/tests/TestCase/VersionComponentTest.php @@ -106,7 +106,7 @@ public function testCanCheckIfVersionComponentIsInDefaultOrNullState( foreach ($actuals as $method => $actual) { // Pre-tests for returning type - $this->assertInternalType('boolean', $actual, $messages[$method].' # Should return a boolean #'); + $this->assertIsBool($actual, $messages[$method].' # Should return a boolean #'); } // Pre-tests for different values diff --git a/tests/TestCase/VersionTest.php b/tests/TestCase/VersionTest.php index 89a8b24..523f086 100644 --- a/tests/TestCase/VersionTest.php +++ b/tests/TestCase/VersionTest.php @@ -72,7 +72,7 @@ public function testIsValid(bool $expected, Version $version) : void ] ); - $this->assertInternalType('boolean', $actual, $message.' # Should return a boolean #'); + $this->assertIsBool($actual, $message.' # Should return a boolean #'); if ($expected === true) { $this->assertTrue($actual, $message);