From e08336fb4de74b2756c59b648386e3d301d1d030 Mon Sep 17 00:00:00 2001 From: jdevinemt <65512359+jdevinemt@users.noreply.github.com> Date: Wed, 11 Feb 2026 15:38:45 -0700 Subject: [PATCH 1/3] Replaced usage of assertEquals() with assertSame() in DropIns\StringToNumberComparison unit tests. Some tests would return a false positive when using assertEquals() because it uses loose comparison. (eg. assertEquals(0, 'true') === true) --- .../DropIns/StringToNumberComparisonTest.php | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/DropIns/StringToNumberComparisonTest.php b/tests/DropIns/StringToNumberComparisonTest.php index 6611394..2dfa37c 100644 --- a/tests/DropIns/StringToNumberComparisonTest.php +++ b/tests/DropIns/StringToNumberComparisonTest.php @@ -164,17 +164,17 @@ public function testNe(): void public function testSpaceship(): void { - $this->assertEquals(0, StringToNumberComparison::spaceship(0, 'a')); - $this->assertEquals(1, StringToNumberComparison::spaceship('0.10', 0)); - $this->assertEquals(-1, StringToNumberComparison::spaceship(0, '0.10')); + $this->assertSame(0, StringToNumberComparison::spaceship(0, 'a')); + $this->assertSame(1, StringToNumberComparison::spaceship('0.10', 0)); + $this->assertSame(-1, StringToNumberComparison::spaceship(0, '0.10')); } public function testSpaceship_WithTrailingWhitespace(): void { - $this->assertEquals(1, StringToNumberComparison::spaceship('1 ', '1')); - $this->assertEquals(-1, StringToNumberComparison::spaceship('1', '1 ')); - $this->assertEquals(0, StringToNumberComparison::spaceship('1', '1')); - $this->assertEquals(0, StringToNumberComparison::spaceship('1 ', '1 ')); + $this->assertSame(1, StringToNumberComparison::spaceship('1 ', '1')); + $this->assertSame(-1, StringToNumberComparison::spaceship('1', '1 ')); + $this->assertSame(0, StringToNumberComparison::spaceship('1', '1')); + $this->assertSame(0, StringToNumberComparison::spaceship('1 ', '1 ')); } public function testInArray(): void @@ -202,7 +202,7 @@ public function testInArray_strict(): void public function testArraySearch(): void { - $this->assertEquals(0, StringToNumberComparison::arraySearch('a', [0], false)); + $this->assertSame(0, StringToNumberComparison::arraySearch('a', [0], false)); } public function testArraySearch_strict(): void @@ -212,10 +212,10 @@ public function testArraySearch_strict(): void public function testArrayKeys(): void { - $this->assertEquals([0 => 0], StringToNumberComparison::arrayKeys([0, 1, 2], 'a', false)); - $this->assertEquals([0 => 0], StringToNumberComparison::arrayKeys([0, 1, 2], '0', false)); + $this->assertSame([0 => 0], StringToNumberComparison::arrayKeys([0, 1, 2], 'a', false)); + $this->assertSame([0 => 0], StringToNumberComparison::arrayKeys([0, 1, 2], '0', false)); - $this->assertEquals( + $this->assertSame( [0 => 0, 1 => 1, 2 => 2], StringToNumberComparison::arrayKeys([0, 0, 0], 'a', false) ); @@ -223,9 +223,9 @@ public function testArrayKeys(): void public function testArrayKeys_strict(): void { - $this->assertEquals([], StringToNumberComparison::arrayKeys([0, 1, 2], 'a', true)); - $this->assertEquals([], StringToNumberComparison::arrayKeys([0, 1, 2], '0', true)); - $this->assertEquals([], StringToNumberComparison::arrayKeys([0, 0, 0], 'a', true)); + $this->assertSame([], StringToNumberComparison::arrayKeys([0, 1, 2], 'a', true)); + $this->assertSame([], StringToNumberComparison::arrayKeys([0, 1, 2], '0', true)); + $this->assertSame([], StringToNumberComparison::arrayKeys([0, 0, 0], 'a', true)); } public function testEq_recursionDoesntMatch(): void @@ -254,14 +254,14 @@ public function testEq_recursionDoesntMatch(): void $this->assertFalse(StringToNumberComparison::eq($innerConfig1, $innerConfig2)); $this->fail(RuntimeException::class . ' expected!'); } catch (RuntimeException $e) { - $this->assertEquals('Recursion limit of 180 was reached!', $e->getMessage()); + $this->assertSame('Recursion limit of 180 was reached!', $e->getMessage()); } try { $this->assertTrue(StringToNumberComparison::ne($innerConfig1, $innerConfig2)); $this->fail(RuntimeException::class . ' expected!'); } catch (RuntimeException $e) { - $this->assertEquals('Recursion limit of 180 was reached!', $e->getMessage()); + $this->assertSame('Recursion limit of 180 was reached!', $e->getMessage()); } StaticDI::reset(); @@ -463,7 +463,7 @@ public function testCharacteristics(): void $readableLeft = $this->getHumanReadableRepresentation($lhs); $readableRight = $this->getHumanReadableRepresentation($rhs); - $this->assertEquals( + $this->assertSame( $native, $computed, $cbComputed From 08035ffe9cad8ef18130cfbb6add145c84d3af06 Mon Sep 17 00:00:00 2001 From: Joe Devine Date: Thu, 12 Feb 2026 16:05:38 -0700 Subject: [PATCH 2/3] Replaced usage of assertEquals() with assertSame() in DiSystem\Container unit tests to be consistent with usage of assertSame() in other unit test classes. --- tests/DiSystem/ContainerTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/DiSystem/ContainerTest.php b/tests/DiSystem/ContainerTest.php index 09bd661..b5e3844 100644 --- a/tests/DiSystem/ContainerTest.php +++ b/tests/DiSystem/ContainerTest.php @@ -90,7 +90,7 @@ public function testGet_invalidArgument(): void public function testGetConfiguration(): void { $diContainer = new Container(); - $this->assertEquals([], $diContainer->getConfiguration()); + $this->assertSame([], $diContainer->getConfiguration()); $localTestClass = new class () implements DebugMode { public function isEnabled(): bool @@ -100,7 +100,7 @@ public function isEnabled(): bool }; $diContainer = new Container([DebugMode::class => get_class($localTestClass)]); - $this->assertEquals([DebugMode::class => get_class($localTestClass)], $diContainer->getConfiguration()); + $this->assertSame([DebugMode::class => get_class($localTestClass)], $diContainer->getConfiguration()); $this->assertInstanceOf(get_class($localTestClass), $diContainer->get(DebugMode::class)); } } From c48e1fa6ffb7538c3ac07ae0df9dab5ae63e7432 Mon Sep 17 00:00:00 2001 From: Joe Devine Date: Thu, 12 Feb 2026 16:11:16 -0700 Subject: [PATCH 3/3] Replaced deprecated implicit nullable parameter definition in DropIns\RecursionInnerValue with explicit definition. --- tests/DropIns/RecursionInnerValue.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/DropIns/RecursionInnerValue.php b/tests/DropIns/RecursionInnerValue.php index 92cabb0..c3429fa 100644 --- a/tests/DropIns/RecursionInnerValue.php +++ b/tests/DropIns/RecursionInnerValue.php @@ -8,7 +8,7 @@ class RecursionInnerValue private $outerValue; - public function __construct(bool $bool, RecursionOuterValue $outerValue = null) + public function __construct(bool $bool, ?RecursionOuterValue $outerValue = null) { $this->bool = $bool; $this->outerValue = $outerValue;