aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbpirkle <bpirkle@wikimedia.org>2024-04-02 22:24:08 -0500
committerbpirkle <bpirkle@wikimedia.org>2024-04-02 22:34:40 -0500
commit532c7cf7ad15c0350ed7680cb65c1fa5f0907eb2 (patch)
treebe68ee06729cef84b76d1dc507091778b1c37d50
parentb3c2d142dfa461274a1b402561ab31039450cace (diff)
downloadmediawikicore-532c7cf7ad15c0350ed7680cb65c1fa5f0907eb2.tar.gz
mediawikicore-532c7cf7ad15c0350ed7680cb65c1fa5f0907eb2.zip
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
-rw-r--r--tests/phpunit/unit/includes/Rest/PathTemplateMatcher/PathMatcherTest.php8
1 files changed, 8 insertions, 0 deletions
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 ] ]
];
}