From b8b4ec98b2f295e8c4368a589ed000e4d65c775c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81mi=20Pelhate?= Date: Thu, 8 Oct 2026 10:49:18 +0200 Subject: [PATCH 1/2] Test against PHPUnit 13 --- composer.json | 2 +- src/Laravel/Constraint/Bus/WasHandledTest.php | 5 ++++- src/Saloon/Doubles/FakeConnectorTest.php | 7 ++++++- src/Saloon/Doubles/SpyConnectorTest.php | 20 ++++++++++++++++++- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index e6aee01..6b07b6c 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "illuminate/contracts": "^12.0|^13.0", "illuminate/support": "^12.0|^13.0", "orchestra/testbench": "^10.0|^11.0", - "phpunit/phpunit": "^11.5|^12.0", + "phpunit/phpunit": "^11.5|^12.0|^13.0", "saloonphp/saloon": "^3.13" }, "suggest": { diff --git a/src/Laravel/Constraint/Bus/WasHandledTest.php b/src/Laravel/Constraint/Bus/WasHandledTest.php index f5c2a74..dcaa3c4 100644 --- a/src/Laravel/Constraint/Bus/WasHandledTest.php +++ b/src/Laravel/Constraint/Bus/WasHandledTest.php @@ -51,7 +51,10 @@ public function itCanMapGivenCallablesToHandleCommands(callable $handler): void { WasHandled::using($handler, $this->app); - $this->assertEquals(new SpyCallable($handler), Bus::getCommandHandler(new stdClass())); + $result = Bus::getCommandHandler(new stdClass()); + + $this->assertInstanceOf(SpyCallable::class, $result); + $this->assertSame($handler, $result->return); } #[Test] diff --git a/src/Saloon/Doubles/FakeConnectorTest.php b/src/Saloon/Doubles/FakeConnectorTest.php index 8bb3523..cf453af 100644 --- a/src/Saloon/Doubles/FakeConnectorTest.php +++ b/src/Saloon/Doubles/FakeConnectorTest.php @@ -6,6 +6,7 @@ use Craftzing\TestBench\Doubles\Callable\SpyCallable; use Craftzing\TestBench\PHPUnit\Constraint\Callables\WasCalled; +use Craftzing\TestBench\PHPUnit\Constraint\PublicPropertiesComparator; use Craftzing\TestBench\PHPUnit\Constraint\StreamInterfaceComparator; use Craftzing\TestBench\PHPUnit\DataProviders\HttpStatusCode; use PHPUnit\Framework\Attributes\DataProviderExternal; @@ -42,6 +43,7 @@ public function itCanApplyNullAuthentication(): void #[Test] public function itAlwaysUsesGuzzleSendersToAvoidSideEffectsOfGlobalState(): void { + $this->registerComparator(new PublicPropertiesComparator(GuzzleSender::class)); $instance = new FakeConnector(); $result = $instance->sender(); @@ -88,7 +90,10 @@ public function itCanSendRequestsWithFakeResponses(HttpStatusCode $httpStatusCod $result = $instance->send($request); - $this->assertEquals($fakeResponse->toResponse($instance), $result); + $this->assertSame($instance, $result->getConnector()); + $this->assertSame($request, $result->getRequest()); + $this->assertSame($fakeResponse->statusCode, $result->status()); + $this->assertSame($fakeResponse->body, $result->json()); } #[Test] diff --git a/src/Saloon/Doubles/SpyConnectorTest.php b/src/Saloon/Doubles/SpyConnectorTest.php index c9b0f49..fc74be6 100644 --- a/src/Saloon/Doubles/SpyConnectorTest.php +++ b/src/Saloon/Doubles/SpyConnectorTest.php @@ -5,16 +5,20 @@ namespace Craftzing\TestBench\Saloon\Doubles; use Craftzing\TestBench\Doubles\Callable\SpyCallable; +use Craftzing\TestBench\PHPUnit\Constraint\PublicPropertiesComparator; use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Saloon\Config; use Saloon\Contracts\Sender; +use Saloon\Data\Pipe; use Saloon\Helpers\MiddlewarePipeline; +use Saloon\Helpers\Pipeline; use Saloon\Http\Auth\BasicAuthenticator; use Saloon\Http\Auth\NullAuthenticator; use Saloon\Http\Connector; use Saloon\Http\Faking\MockClient; use Saloon\Http\Faking\MockResponse; +use Saloon\Http\Senders\GuzzleSender; final class SpyConnectorTest extends TestCase { @@ -95,7 +99,20 @@ public function itCanOverwriteInheritedMiddlewareFromDecoratedConnector(): void $result = $instance->middleware()->merge($middlewarePipeline); - $this->assertEquals($middlewarePipeline, $result); + $this->assertSame($instance->middleware(), $result); + $this->assertSamePipes($middlewarePipeline->getRequestPipeline(), $result->getRequestPipeline()); + $this->assertSamePipes($middlewarePipeline->getResponsePipeline(), $result->getResponsePipeline()); + $this->assertSamePipes($middlewarePipeline->getFatalPipeline(), $result->getFatalPipeline()); + } + + private function assertSamePipes(Pipeline $expected, Pipeline $actual): void + { + $describe = static fn(Pipeline $pipeline): array => array_map( + static fn(Pipe $pipe): array => [$pipe->callable, $pipe->name, $pipe->order], + $pipeline->getPipes(), + ); + + $this->assertSame($describe($expected), $describe($actual)); } #[Test] @@ -137,6 +154,7 @@ public function itCanOverwriteInheritedMockClientFromDecoratedConnector(): void #[Test] public function itCanHandleNoDefaultSender(): void { + $this->registerComparator(new PublicPropertiesComparator(GuzzleSender::class)); $instance = new SpyConnector(); $result = $instance->sender(); From d954aac7f6a22a55e45d2b399386a0cba3b8fc22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Re=CC=81mi=20Pelhate?= Date: Thu, 8 Oct 2026 11:28:49 +0200 Subject: [PATCH 2/2] SA fixes --- mago.toml | 2 +- src/Saloon/Doubles/SpyConnectorTest.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/mago.toml b/mago.toml index 00d2762..042cc71 100644 --- a/mago.toml +++ b/mago.toml @@ -1,5 +1,5 @@ extends = "mago.dist.toml" -version = "1.47" +version = "1.53" php-version = "8.4.0" [source] diff --git a/src/Saloon/Doubles/SpyConnectorTest.php b/src/Saloon/Doubles/SpyConnectorTest.php index fc74be6..1028647 100644 --- a/src/Saloon/Doubles/SpyConnectorTest.php +++ b/src/Saloon/Doubles/SpyConnectorTest.php @@ -20,6 +20,8 @@ use Saloon\Http\Faking\MockResponse; use Saloon\Http\Senders\GuzzleSender; +use function array_map; + final class SpyConnectorTest extends TestCase { #[Test]