mirror of
https://github.com/FOSSBilling/FOSSBilling.git
synced 2026-11-30 04:07:07 +09:00
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>
This commit is contained in:
1 parent
d6c21c4b4a
commit
e2e9ff1125
1 file changed
+13
@@ -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');
|
||||
|
||||
|
||||
Reference in new issue
Block a user