37 $info = $dispatcher->dispatch($method, $uri);
38 $this->assertSame($dispatcher::FOUND,
$info[0]);
40 $this->assertSame($argDict,
$info[2]);
49 $routeInfo = $dispatcher->dispatch($method, $uri);
50 $this->assertArrayNotHasKey(1, $routeInfo,
51 'NOT_FOUND result must only contain a single element in the returned info array' 53 $this->assertSame($dispatcher::NOT_FOUND, $routeInfo[0]);
62 $routeInfo = $dispatcher->dispatch($method, $uri);
63 $this->assertArrayHasKey(1, $routeInfo,
64 'METHOD_NOT_ALLOWED result must return an array of allowed methods at index 1' 67 list($routedStatus, $methodArray) = $dispatcher->dispatch($method, $uri);
68 $this->assertSame($dispatcher::METHOD_NOT_ALLOWED, $routedStatus);
69 $this->assertSame($availableMethods, $methodArray);
79 $r->
addRoute(
'GET',
'/foo/{test}/{test:\d+}',
'handler0');
90 $r->
addRoute(
'GET',
'/user/{id}',
'handler0');
91 $r->
addRoute(
'GET',
'/user/{name}',
'handler1');
102 $r->
addRoute(
'GET',
'/user',
'handler0');
103 $r->
addRoute(
'GET',
'/user',
'handler1');
114 $r->
addRoute(
'GET',
'/user/{name}',
'handler0');
115 $r->
addRoute(
'GET',
'/user/nikic',
'handler1');
126 $r->
addRoute(
'GET',
'/{lang:(en|de)}',
'handler0');
137 $r->addRoute(
'GET',
'/resource/123/456',
'handler0');
141 $uri =
'/resource/123/456';
145 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
150 $r->addRoute(
'GET',
'/handler0',
'handler0');
151 $r->addRoute(
'GET',
'/handler1',
'handler1');
152 $r->addRoute(
'GET',
'/handler2',
'handler2');
157 $handler =
'handler2';
160 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
165 $r->addRoute(
'GET',
'/user/{name}/{id:[0-9]+}',
'handler0');
166 $r->addRoute(
'GET',
'/user/{id:[0-9]+}',
'handler1');
167 $r->addRoute(
'GET',
'/user/{name}',
'handler2');
171 $uri =
'/user/rdlowrey';
172 $handler =
'handler2';
173 $argDict = [
'name' =>
'rdlowrey'];
175 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
182 $uri =
'/user/12345';
183 $handler =
'handler1';
184 $argDict = [
'id' =>
'12345'];
186 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
194 $handler =
'handler2';
195 $argDict = [
'name' =>
'NaN'];
197 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
204 $uri =
'/user/rdlowrey/12345';
205 $handler =
'handler0';
206 $argDict = [
'name' =>
'rdlowrey',
'id' =>
'12345'];
208 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
213 $r->addRoute(
'GET',
'/user/{id:[0-9]+}',
'handler0');
214 $r->addRoute(
'GET',
'/user/12345/extension',
'handler1');
215 $r->addRoute(
'GET',
'/user/{id:[0-9]+}.{extension}',
'handler2');
219 $uri =
'/user/12345.svg';
220 $handler =
'handler2';
221 $argDict = [
'id' =>
'12345',
'extension' =>
'svg'];
223 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
228 $r->addRoute(
'GET',
'/user/{name}',
'handler0');
229 $r->addRoute(
'GET',
'/user/{name}/{id:[0-9]+}',
'handler1');
230 $r->addRoute(
'GET',
'/static0',
'handler2');
231 $r->addRoute(
'GET',
'/static1',
'handler3');
232 $r->addRoute(
'HEAD',
'/static1',
'handler4');
236 $uri =
'/user/rdlowrey';
237 $handler =
'handler0';
238 $argDict = [
'name' =>
'rdlowrey'];
240 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
247 $uri =
'/user/rdlowrey/1234';
248 $handler =
'handler1';
249 $argDict = [
'name' =>
'rdlowrey',
'id' =>
'1234'];
251 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
259 $handler =
'handler2';
262 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
270 $handler =
'handler4';
273 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
278 $r->addRoute(
'GET',
'/user/{name}',
'handler0');
279 $r->addRoute(
'POST',
'/user/{name:[a-z]+}',
'handler1');
283 $uri =
'/user/rdlowrey';
284 $handler =
'handler1';
285 $argDict = [
'name' =>
'rdlowrey'];
287 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
292 $r->addRoute(
'GET',
'/user/{name}',
'handler0');
293 $r->addRoute(
'POST',
'/user/{name:[a-z]+}',
'handler1');
294 $r->addRoute(
'POST',
'/user/{name}',
'handler2');
298 $uri =
'/user/rdlowrey';
299 $handler =
'handler1';
300 $argDict = [
'name' =>
'rdlowrey'];
302 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
307 $r->addRoute(
'GET',
'/user/{name}',
'handler0');
308 $r->addRoute(
'GET',
'/user/{name}/edit',
'handler1');
312 $uri =
'/user/rdlowrey/edit';
313 $handler =
'handler1';
314 $argDict = [
'name' =>
'rdlowrey'];
316 $cases[] = [$method, $uri, $callback,
$handler, $argDict];
321 $r->addRoute([
'GET',
'POST'],
'/user',
'handlerGetPost');
322 $r->addRoute([
'DELETE'],
'/user',
'handlerDelete');
323 $r->addRoute([],
'/user',
'handlerNone');
327 $cases[] = [
'GET',
'/user', $callback,
'handlerGetPost', $argDict];
328 $cases[] = [
'POST',
'/user', $callback,
'handlerGetPost', $argDict];
329 $cases[] = [
'DELETE',
'/user', $callback,
'handlerDelete', $argDict];
334 $r->addRoute(
'POST',
'/user.json',
'handler0');
335 $r->addRoute(
'GET',
'/{entity}.json',
'handler1');
338 $cases[] = [
'GET',
'/user.json', $callback,
'handler1', [
'entity' =>
'user']];
343 $r->addRoute(
'GET',
'',
'handler0');
346 $cases[] = [
'GET',
'', $callback,
'handler0', []];
351 $r->addRoute(
'HEAD',
'/a/{foo}',
'handler0');
352 $r->addRoute(
'GET',
'/b/{foo}',
'handler1');
355 $cases[] = [
'HEAD',
'/b/bar', $callback,
'handler1', [
'foo' =>
'bar']];
360 $r->addRoute(
'HEAD',
'/a',
'handler0');
361 $r->addRoute(
'GET',
'/b',
'handler1');
364 $cases[] = [
'HEAD',
'/b', $callback,
'handler1', []];
369 $r->addRoute(
'GET',
'/foo',
'handler0');
370 $r->addRoute(
'HEAD',
'/{bar}',
'handler1');
373 $cases[] = [
'HEAD',
'/foo', $callback,
'handler1', [
'bar' =>
'foo']];
378 $r->addRoute(
'*',
'/user',
'handler0');
379 $r->addRoute(
'*',
'/{user}',
'handler1');
380 $r->addRoute(
'GET',
'/user',
'handler2');
383 $cases[] = [
'GET',
'/user', $callback,
'handler2', []];
388 $r->addRoute(
'*',
'/user',
'handler0');
389 $r->addRoute(
'GET',
'/user',
'handler1');
392 $cases[] = [
'POST',
'/user', $callback,
'handler0', []];
396 $cases[] = [
'HEAD',
'/user', $callback,
'handler1', []];
401 $r->addRoute(
'GET',
'/{bar}',
'handler0');
402 $r->addRoute(
'*',
'/foo',
'handler1');
405 $cases[] = [
'GET',
'/foo', $callback,
'handler0', [
'bar' =>
'foo']];
410 $r->addRoute(
'GET',
'/user',
'handler0');
411 $r->addRoute(
'*',
'/{foo:.*}',
'handler1');
414 $cases[] = [
'POST',
'/bar', $callback,
'handler1', [
'foo' =>
'bar']];
428 $r->addRoute(
'GET',
'/resource/123/456',
'handler0');
434 $cases[] = [$method, $uri, $callback];
442 $cases[] = [$method, $uri, $callback];
450 $cases[] = [$method, $uri, $callback];
455 $r->addRoute(
'GET',
'/handler0',
'handler0');
456 $r->addRoute(
'GET',
'/handler1',
'handler1');
457 $r->addRoute(
'GET',
'/handler2',
'handler2');
463 $cases[] = [$method, $uri, $callback];
468 $r->addRoute(
'GET',
'/user/{name}/{id:[0-9]+}',
'handler0');
469 $r->addRoute(
'GET',
'/user/{id:[0-9]+}',
'handler1');
470 $r->addRoute(
'GET',
'/user/{name}',
'handler2');
476 $cases[] = [$method, $uri, $callback];
482 $uri =
'/user/rdlowrey/12345/not-found';
484 $cases[] = [$method, $uri, $callback];
491 $cases[] = [$method, $uri, $callback];
505 $r->addRoute(
'GET',
'/resource/123/456',
'handler0');
509 $uri =
'/resource/123/456';
510 $allowedMethods = [
'GET'];
512 $cases[] = [$method, $uri, $callback, $allowedMethods];
517 $r->addRoute(
'GET',
'/resource/123/456',
'handler0');
518 $r->addRoute(
'POST',
'/resource/123/456',
'handler1');
519 $r->addRoute(
'PUT',
'/resource/123/456',
'handler2');
520 $r->addRoute(
'*',
'/',
'handler3');
524 $uri =
'/resource/123/456';
525 $allowedMethods = [
'GET',
'POST',
'PUT'];
527 $cases[] = [$method, $uri, $callback, $allowedMethods];
532 $r->addRoute(
'GET',
'/user/{name}/{id:[0-9]+}',
'handler0');
533 $r->addRoute(
'POST',
'/user/{name}/{id:[0-9]+}',
'handler1');
534 $r->addRoute(
'PUT',
'/user/{name}/{id:[0-9]+}',
'handler2');
535 $r->addRoute(
'PATCH',
'/user/{name}/{id:[0-9]+}',
'handler3');
539 $uri =
'/user/rdlowrey/42';
540 $allowedMethods = [
'GET',
'POST',
'PUT',
'PATCH'];
542 $cases[] = [$method, $uri, $callback, $allowedMethods];
547 $r->addRoute(
'POST',
'/user/{name}',
'handler1');
548 $r->addRoute(
'PUT',
'/user/{name:[a-z]+}',
'handler2');
549 $r->addRoute(
'PATCH',
'/user/{name:[a-z]+}',
'handler3');
553 $uri =
'/user/rdlowrey';
554 $allowedMethods = [
'POST',
'PUT',
'PATCH'];
556 $cases[] = [$method, $uri, $callback, $allowedMethods];
561 $r->addRoute([
'GET',
'POST'],
'/user',
'handlerGetPost');
562 $r->addRoute([
'DELETE'],
'/user',
'handlerDelete');
563 $r->addRoute([],
'/user',
'handlerNone');
566 $cases[] = [
'PUT',
'/user', $callback, [
'GET',
'POST',
'DELETE']];
571 $r->addRoute(
'POST',
'/user.json',
'handler0');
572 $r->addRoute(
'GET',
'/{entity}.json',
'handler1');
575 $cases[] = [
'PUT',
'/user.json', $callback, [
'POST',
'GET']];
testShadowedStaticRoute()
Static route "/user/nikic" is shadowed by previously defined variable route "/user/([^/]+)" for metho...
testCapturing()
Regex "(en|de)" for parameter "lang" contains a capturing group
testFoundDispatches($method, $uri, $callback, $handler, $argDict)
provideFoundDispatchCases
getDispatcherClass()
Delegate dispatcher selection to child test classes.
testDuplicateStaticRoute()
Cannot register two routes matching "/user" for method "GET"
testDuplicateVariableNameError()
Cannot use the same placeholder "test" twice
provideFoundDispatchCases()
addRoute($httpMethod, $route, $handler)
Adds a route to the collection.
provideNotFoundDispatchCases()
testDuplicateVariableRoute()
Cannot register two routes matching "/user/([^/]+)" for method "GET"
testMethodNotAllowedDispatches($method, $uri, $callback, $availableMethods)
provideMethodNotAllowedDispatchCases
generateDispatcherOptions()
Set appropriate options for the specific Dispatcher class we're testing.
testNotFoundDispatches($method, $uri, $callback)
provideNotFoundDispatchCases
getDataGeneratorClass()
Delegate dataGenerator selection to child test classes.
provideMethodNotAllowedDispatchCases()