From 8c0efd0d9317ad92bd55cd6afcd41bdbab827bf8 Mon Sep 17 00:00:00 2001 From: Sam Light Date: Wed, 10 Jun 2026 19:00:32 +0100 Subject: Make basic routing work --- tests/Unit/BasicStrategyTest.php | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 tests/Unit/BasicStrategyTest.php (limited to 'tests/Unit/BasicStrategyTest.php') diff --git a/tests/Unit/BasicStrategyTest.php b/tests/Unit/BasicStrategyTest.php new file mode 100644 index 0000000..2a0b550 --- /dev/null +++ b/tests/Unit/BasicStrategyTest.php @@ -0,0 +1,44 @@ +expect(fn() => new BasicStrategy) + ->toBeInstanceOf(BasicStrategy::class); + +it('throws on not found', function() { + (new BasicStrategy)->notFound( + (new Psr17Factory)->createServerRequest( + HttpMethod::Get->value, + '/testing/testing' + ) + ); +})->throws(NotFoundException::class); + +it('calls route', function () { + $factory = new Psr17Factory; + $response = $factory->createResponse(200, 'OK'); + $cb = TestCallable::make(fn () => $response); + $res = (new BasicStrategy)->runRoute($rc = new RouteCall( + $factory->createServerRequest( + HttpMethod::Get->value, + '/testing/testing' + ), + new Route( + HttpMethod::Get, + $cb + ), + [] + )); + + $cb->assertIsCalled(); + $call = $cb->getLastCall(); + expect($call->args[0] ?? null)->toBe($rc); + expect($res)->toBe($response); +}); -- cgit v1.2.3