Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion mago.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extends = "mago.dist.toml"
version = "1.47"
version = "1.53"
php-version = "8.4.0"

[source]
Expand Down
5 changes: 4 additions & 1 deletion src/Laravel/Constraint/Bus/WasHandledTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
7 changes: 6 additions & 1 deletion src/Saloon/Doubles/FakeConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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]
Expand Down
22 changes: 21 additions & 1 deletion src/Saloon/Doubles/SpyConnectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
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;

use function array_map;

final class SpyConnectorTest extends TestCase
{
Expand Down Expand Up @@ -95,7 +101,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]
Expand Down Expand Up @@ -137,6 +156,7 @@ public function itCanOverwriteInheritedMockClientFromDecoratedConnector(): void
#[Test]
public function itCanHandleNoDefaultSender(): void
{
$this->registerComparator(new PublicPropertiesComparator(GuzzleSender::class));
$instance = new SpyConnector();

$result = $instance->sender();
Expand Down
Loading