From 532c7cf7ad15c0350ed7680cb65c1fa5f0907eb2 Mon Sep 17 00:00:00 2001 From: bpirkle Date: Tue, 2 Apr 2024 22:24:08 -0500 Subject: Add additional PathMatcher test cases In T359652 we are contemplating disallowing optional path parameters in the REST API. Related investigation shows we are lacking test cases for some current edge case path matching behaviors. Add tests for these, to make the current behavior explicit. If we decide to disallow optional path parameters, these new tests will need to be revised. This is good. A change in behavior should result in failing tests, and without these new test cases, it would not. Bug: T359652 Change-Id: Ibc0880ba0f6ea199a91fc7fc81577519989d32df --- .../unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php b/tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php index 38f6a63f0658..8df7eac6fac6 100644 --- a/tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php +++ b/tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php @@ -17,6 +17,9 @@ class PathMatcherTest extends MediaWikiUnitTestCase { '/c/{x}/d', '/c/{x}/e', '/c/{x}/{y}/d', + '/d/', + '/', + '/d//e' ]; public static function provideConflictingRoutes() { @@ -27,6 +30,8 @@ class PathMatcherTest extends MediaWikiUnitTestCase { [ '/b/a', 1, '/b/{x}' ], [ '/b/{x}', 1, '/b/{x}' ], [ '/{x}/{y}/d', 2, '/c/{x}/d' ], + [ '/d/{x}', 5, '/d/' ], + [ '/{x}', 6, '/' ] ]; } @@ -42,6 +47,9 @@ class PathMatcherTest extends MediaWikiUnitTestCase { [ '/c/1/f', false ], [ '/c//e', [ 'params' => [ 'x' => '' ], 'userData' => 3 ] ], [ '/c///e', false ], + [ '/d/', [ 'params' => [], 'userData' => 5 ] ], + [ '/', [ 'params' => [], 'userData' => 6 ] ], + [ '/d//e', [ 'params' => [], 'userData' => 7 ] ] ]; } -- cgit v1.2.3