From e2e9ff1125873a808dbeb2d73c8be5eadece9b24 Mon Sep 17 00:00:00 2001 From: Adam Daley Date: Tue, 7 Jul 2026 06:00:42 +0100 Subject: [PATCH] Fixes for 2 code quality findings in RouterMatcherTest (#3930) * Apply suggested fix to tests/Unit/FOSSBilling/RouteMatcherTest.php from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> * Apply suggested fix to tests/Unit/FOSSBilling/RouteMatcherTest.php from Copilot Autofix Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --------- Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com> --- tests/Unit/FOSSBilling/RouteMatcherTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Unit/FOSSBilling/RouteMatcherTest.php b/tests/Unit/FOSSBilling/RouteMatcherTest.php index ee8f6b5ef..63310701a 100644 --- a/tests/Unit/FOSSBilling/RouteMatcherTest.php +++ b/tests/Unit/FOSSBilling/RouteMatcherTest.php @@ -11,6 +11,12 @@ test('route matcher matches exact routes for the same HTTP method', function (): ->and($match->params)->toBe([]); }); +test('route matcher rejects non-matching paths for the same HTTP method', function (): void { + $match = (new RouteMatcher())->match('get', '/invoice', [], '/invoices', 'GET'); + + expect($match->matched)->toBeFalse(); +}); + test('route matcher rejects different HTTP methods', function (): void { $match = (new RouteMatcher())->match('post', '/invoice', [], '/invoice', 'GET'); @@ -48,6 +54,13 @@ test('route matcher accepts null conditions for routes without constrained param expect($match->matched)->toBeTrue(); }); +test('route matcher uses default parameter pattern when conditions are null', function (): void { + $match = (new RouteMatcher())->match('get', '/item/:id', null, '/item/42', 'GET'); + + expect($match->matched)->toBeTrue() + ->and($match->params)->toBe(['id' => '42']); +}); + test('route matcher extracts full placeholder names', function (): void { $match = (new RouteMatcher())->match('get', '/item/:item_id', ['item_id' => '[0-9]+'], '/item/42', 'GET');