18 $router->
add(
"/wiki/$1" );
19 $this->basicRouter = $router;
26 $matches = $this->basicRouter->parse(
"/wiki/Foo" );
27 $this->assertEquals(
$matches, [
'title' =>
"Foo" ] );
35 $router->
add(
"/" ); # Should be the same as
"/$1"
37 $this->assertEquals(
$matches, [
'title' =>
"Foo" ] );
40 $router->
add(
"/wiki" ); # Should be the same as /wiki/
$1
41 $matches = $router->parse(
"/wiki/Foo" );
42 $this->assertEquals(
$matches, [
'title' =>
"Foo" ] );
45 $router->
add(
"/wiki/" ); # Should be the same as /wiki/
$1
46 $matches = $router->parse(
"/wiki/Foo" );
47 $this->assertEquals(
$matches, [
'title' =>
"Foo" ] );
55 $router->
add(
"/$1" );
56 $router->add(
"/a/$1" );
57 $router->add(
"/b/$1" );
58 $matches = $router->parse(
"/a/Foo" );
59 $this->assertEquals(
$matches, [
'title' =>
"Foo" ] );
62 $router->
add(
"/b/$1" );
63 $router->add(
"/a/$1" );
64 $router->add(
"/$1" );
65 $matches = $router->parse(
"/a/Foo" );
66 $this->assertEquals(
$matches, [
'title' =>
"Foo" ] );
74 $router->
add( [
'edit' =>
"/edit/$1" ], [
'action' =>
'$key' ] );
75 $matches = $router->parse(
"/edit/Foo" );
76 $this->assertEquals(
$matches, [
'title' =>
"Foo",
'action' =>
'edit' ] );
85 $router->
add(
'/$2/$1', [
'test' =>
'$2' ] );
86 $matches = $router->parse(
"/asdf/Foo" );
87 $this->assertEquals(
$matches, [
'title' =>
"Foo",
'test' =>
'asdf' ] );
95 $router->
add(
'/$2/$1',
97 [
'$2' => [
'a',
'b' ] ]
99 $router->add(
'/$2/$1',
103 $router->add(
'/$1' );
105 $matches = $router->parse(
"/asdf/Foo" );
106 $this->assertEquals(
$matches, [
'title' =>
"asdf/Foo" ] );
108 $matches = $router->parse(
"/a/Foo" );
109 $this->assertEquals(
$matches, [
'title' =>
"Foo",
'test' =>
'a' ] );
111 $matches = $router->parse(
"/c/Foo" );
112 $this->assertEquals(
$matches, [
'title' =>
"Foo",
'test2' =>
'c' ] );
123 [
'a' =>
'b',
'data:foo' =>
'bar' ],
124 [
'callback' => [ $this,
'callbackForTest' ] ]
126 $matches = $router->parse(
'/Foo' );
140 $router->
add(
"/wiki/$1", [
'title' =>
"$1$2" ] );
141 $matches = $router->parse(
"/wiki/A" );
142 $this->assertEquals( [],
$matches );
150 $router->
addStrict(
"/Bar", [
'ping' =>
'pong' ] );
151 $router->add(
"/asdf-$1", [
'title' =>
'qwerty-$1' ] );
152 $router->add(
"/$1" );
153 $router->add(
"/qwerty-$1", [
'title' =>
'asdf-$1' ] );
154 $router->addStrict(
"/Baz", [
'marco' =>
'polo' ] );
155 $router->add(
"/a/$1" );
156 $router->add(
"/asdf/$1" );
157 $router->add(
"/$2/$1", [
'unrestricted' =>
'$2' ] );
158 $router->add( [
'qwerty' =>
"/qwerty/$1" ], [
'qwerty' =>
'$key' ] );
159 $router->add(
"/$2/$1", [
'restricted-to-y' =>
'$2' ], [
'$2' =>
'y' ] );
163 '/Foo' => [
'title' =>
'Foo' ],
164 '/Bar' => [
'ping' =>
'pong' ],
165 '/Baz' => [
'marco' =>
'polo' ],
166 '/asdf-foo' => [
'title' =>
'qwerty-foo' ],
167 '/qwerty-bar' => [
'title' =>
'asdf-bar' ],
168 '/a/Foo' => [
'title' =>
'Foo' ],
169 '/asdf/Foo' => [
'title' =>
'Foo' ],
170 '/qwerty/Foo' => [
'title' =>
'Foo',
'qwerty' =>
'qwerty' ],
171 '/baz/Foo' => [
'title' =>
'Foo',
'unrestricted' =>
'baz' ],
172 '/y/Foo' => [
'title' =>
'Foo',
'restricted-to-y' =>
'y' ],
173 ] as $path => $result
175 $this->assertEquals( $router->parse( $path ), $result );
183 $matches = $this->basicRouter->parse(
"/wiki/Special:Recentchanges" );
184 $this->assertEquals(
$matches, [
'title' =>
"Special:Recentchanges" ] );
191 $matches = $this->basicRouter->parse(
"/wiki/Title_With%20Space" );
192 $this->assertEquals(
$matches, [
'title' =>
"Title_With Space" ] );
209 $matches = $this->basicRouter->parse(
"/wiki/$char" );
210 $this->assertEquals(
$matches, [
'title' =>
"$char" ] );
217 $matches = $this->basicRouter->parse(
"/wiki/Plus+And&Dollar\\Stuff();[]{}*" );
218 $this->assertEquals(
$matches, [
'title' =>
"Plus+And&Dollar\\Stuff();[]{}*" ] );
228 $matches = $this->basicRouter->parse(
"/wiki/Spécial:Modifications_récentes" );
229 $this->assertEquals(
$matches, [
'title' =>
"Spécial:Modifications_récentes" ] );
231 $matches = $this->basicRouter->parse(
"/wiki/Sp%C3%A9cial:Modifications_r%C3%A9centes" );
232 $this->assertEquals(
$matches, [
'title' =>
"Spécial:Modifications_récentes" ] );
240 $matches = $this->basicRouter->parse(
241 "/wiki/Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum."
245 [
'title' =>
"Lorem_ipsum_dolor_sit_amet,_consectetur_adipisicing_elit,_sed_do_eiusmod_tempor_incididunt_ut_labore_et_dolore_magna_aliqua._Ut_enim_ad_minim_veniam,_quis_nostrud_exercitation_ullamco_laboris_nisi_ut_aliquip_ex_ea_commodo_consequat._Duis_aute_irure_dolor_in_reprehenderit_in_voluptate_velit_esse_cillum_dolore_eu_fugiat_nulla_pariatur._Excepteur_sint_occaecat_cupidatat_non_proident,_sunt_in_culpa_qui_officia_deserunt_mollit_anim_id_est_laborum." ]
255 $router->
add(
"/wiki/$1", [
'title' =>
'%20:$1' ] );
256 $matches = $router->parse(
"/wiki/Foo" );
257 $this->assertEquals(
$matches, [
'title' =>
'%20:Foo' ] );
265 $router->
add(
"/wiki/$1", [
'title' => [
'value' =>
'bar%20$1' ] ] );
266 $matches = $router->parse(
"/wiki/Foo" );
267 $this->assertEquals(
$matches, [
'title' =>
'bar%20$1' ] );
Tests for the PathRouter parsing.
testOrder()
Test to ensure that path is based on specifity, not order.
testAdditionalParameter()
Test the handling of $2 inside paths.
testFail()
Test to ensure that matches are not made if a parameter expects nonexistent input.
testWeight()
Test to ensure weight of paths is handled correctly.
testRawParamValue()
Ensure that raw parameter values do not have any variable replacements or urldecoding.
testRegexpChars( $char)
Make sure the router doesn't break on special characters like $ used in regexp replacements provideRe...
testUrlencoding()
Make sure the router decodes urlencoding properly.
testLoose()
Test loose path auto-$1.
callbackForTest(&$matches, $data)
testCharacters()
Make sure the router handles characters like +&() properly.
static provideRegexpChars()
testUnicode()
Make sure the router handles unicode characters correctly @depends testSpecial @depends testUrlencodi...
testPatternUrlencoding()
Ensure that the php passed site of parameter values are not urldecoded.
testSpecial()
Make sure the router handles titles like Special:Recentchanges correctly.
testKeyParameter()
Test the handling of key based arrays with a url parameter.
testBasic()
Test basic path parsing.
testLength()
Ensure the router doesn't choke on long paths.
testRestrictedValue()
Test additional restricted value parameter.
add( $path, $params=[], $options=[])
Add a new path pattern to the path router.
addStrict( $path, $params=[], $options=[])
Add a new path pattern to the path router with the strict option on.