UrlRuleTest.php 16.2 KB
Newer Older
Qiang Xue committed
1 2 3 4
<?php

namespace yiiunit\framework\web;

Qiang Xue committed
5
use yii\web\UrlManager;
Qiang Xue committed
6
use yii\web\UrlRule;
Qiang Xue committed
7
use yii\web\Request;
Alexander Makarov committed
8
use yiiunit\TestCase;
Qiang Xue committed
9

10 11 12
/**
 * @group web
 */
Alexander Makarov committed
13
class UrlRuleTest extends TestCase
Qiang Xue committed
14 15 16
{
	public function testCreateUrl()
	{
Alexander Makarov committed
17
		$manager = new UrlManager(['cache' => null]);
Qiang Xue committed
18 19 20 21 22 23
		$suites = $this->getTestsForCreateUrl();
		foreach ($suites as $i => $suite) {
			list ($name, $config, $tests) = $suite;
			$rule = new UrlRule($config);
			foreach ($tests as $j => $test) {
				list ($route, $params, $expected) = $test;
Qiang Xue committed
24
				$url = $rule->createUrl($manager, $route, $params);
Qiang Xue committed
25 26 27 28 29
				$this->assertEquals($expected, $url, "Test#$i-$j: $name");
			}
		}
	}

Qiang Xue committed
30
	public function testParseRequest()
Qiang Xue committed
31
	{
Alexander Makarov committed
32 33
		$manager = new UrlManager(['cache' => null]);
		$request = new Request(['hostInfo' => 'http://en.example.com']);
Qiang Xue committed
34
		$suites = $this->getTestsForParseRequest();
Qiang Xue committed
35 36 37 38
		foreach ($suites as $i => $suite) {
			list ($name, $config, $tests) = $suite;
			$rule = new UrlRule($config);
			foreach ($tests as $j => $test) {
Qiang Xue committed
39
				$request->pathInfo = $test[0];
Qiang Xue committed
40
				$route = $test[1];
Alexander Makarov committed
41
				$params = isset($test[2]) ? $test[2] : [];
Qiang Xue committed
42
				$result = $rule->parseRequest($manager, $request);
Qiang Xue committed
43 44 45
				if ($route === false) {
					$this->assertFalse($result, "Test#$i-$j: $name");
				} else {
Alexander Makarov committed
46
					$this->assertEquals([$route, $params], $result, "Test#$i-$j: $name");
Qiang Xue committed
47 48 49 50 51 52 53 54 55 56 57 58 59 60
				}
			}
		}
	}

	protected function getTestsForCreateUrl()
	{
		// structure of each test
		//   message for the test
		//   config for the URL rule
		//   list of inputs and outputs
		//     route
		//     params
		//     expected output
Alexander Makarov committed
61 62
		return [
			[
Qiang Xue committed
63
				'empty pattern',
Alexander Makarov committed
64
				[
Qiang Xue committed
65 66
					'pattern' => '',
					'route' => 'post/index',
Alexander Makarov committed
67 68 69 70 71 72 73 74
				],
				[
					['post/index', [], ''],
					['comment/index', [], false],
					['post/index', ['page' => 1], '?page=1'],
				],
			],
			[
Qiang Xue committed
75
				'without param',
Alexander Makarov committed
76
				[
Qiang Xue committed
77 78
					'pattern' => 'posts',
					'route' => 'post/index',
Alexander Makarov committed
79 80 81 82 83 84 85 86
				],
				[
					['post/index', [], 'posts'],
					['comment/index', [], false],
					['post/index', ['page' => 1], 'posts?page=1'],
				],
			],
			[
Qiang Xue committed
87
				'parsing only',
Alexander Makarov committed
88
				[
Qiang Xue committed
89 90 91
					'pattern' => 'posts',
					'route' => 'post/index',
					'mode' => UrlRule::PARSING_ONLY,
Alexander Makarov committed
92 93 94 95 96 97
				],
				[
					['post/index', [], false],
				],
			],
			[
Qiang Xue committed
98
				'with param',
Alexander Makarov committed
99
				[
Qiang Xue committed
100 101
					'pattern' => 'post/<page>',
					'route' => 'post/index',
Alexander Makarov committed
102 103 104 105 106 107 108 109 110
				],
				[
					['post/index', [], false],
					['comment/index', [], false],
					['post/index', ['page' => 1], 'post/1'],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/1?tag=a'],
				],
			],
			[
Qiang Xue committed
111
				'with param requirement',
Alexander Makarov committed
112
				[
Qiang Xue committed
113 114
					'pattern' => 'post/<page:\d+>',
					'route' => 'post/index',
Alexander Makarov committed
115 116 117 118 119 120 121 122
				],
				[
					['post/index', ['page' => 'abc'], false],
					['post/index', ['page' => 1], 'post/1'],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/1?tag=a'],
				],
			],
			[
Qiang Xue committed
123
				'with multiple params',
Alexander Makarov committed
124
				[
Qiang Xue committed
125 126
					'pattern' => 'post/<page:\d+>-<tag>',
					'route' => 'post/index',
Alexander Makarov committed
127 128 129 130 131 132 133 134
				],
				[
					['post/index', ['page' => '1abc'], false],
					['post/index', ['page' => 1], false],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/1-a'],
				],
			],
			[
Qiang Xue committed
135
				'with optional param',
Alexander Makarov committed
136
				[
Qiang Xue committed
137 138
					'pattern' => 'post/<page:\d+>/<tag>',
					'route' => 'post/index',
Alexander Makarov committed
139 140 141 142 143 144 145 146 147 148
					'defaults' => ['page' => 1],
				],
				[
					['post/index', ['page' => 1], false],
					['post/index', ['page' => '1abc', 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/a'],
					['post/index', ['page' => 2, 'tag' => 'a'], 'post/2/a'],
				],
			],
			[
Qiang Xue committed
149
				'with optional param not in pattern',
Alexander Makarov committed
150
				[
Qiang Xue committed
151 152
					'pattern' => 'post/<tag>',
					'route' => 'post/index',
Alexander Makarov committed
153 154 155 156 157 158 159 160 161 162
					'defaults' => ['page' => 1],
				],
				[
					['post/index', ['page' => 1], false],
					['post/index', ['page' => '1abc', 'tag' => 'a'], false],
					['post/index', ['page' => 2, 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/a'],
				],
			],
			[
Qiang Xue committed
163
				'multiple optional params',
Alexander Makarov committed
164
				[
Qiang Xue committed
165 166
					'pattern' => 'post/<page:\d+>/<tag>/<sort:yes|no>',
					'route' => 'post/index',
Alexander Makarov committed
167 168 169 170 171 172 173 174 175 176 177 178 179
					'defaults' => ['page' => 1, 'sort' => 'yes'],
				],
				[
					['post/index', ['page' => 1], false],
					['post/index', ['page' => '1abc', 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a', 'sort' => 'YES'], false],
					['post/index', ['page' => 1, 'tag' => 'a', 'sort' => 'yes'], 'post/a'],
					['post/index', ['page' => 2, 'tag' => 'a', 'sort' => 'yes'], 'post/2/a'],
					['post/index', ['page' => 2, 'tag' => 'a', 'sort' => 'no'], 'post/2/a/no'],
					['post/index', ['page' => 1, 'tag' => 'a', 'sort' => 'no'], 'post/a/no'],
				],
			],
			[
Qiang Xue committed
180
				'optional param and required param separated by dashes',
Alexander Makarov committed
181
				[
Qiang Xue committed
182 183
					'pattern' => 'post/<page:\d+>-<tag>',
					'route' => 'post/index',
Alexander Makarov committed
184 185 186 187 188 189 190 191 192 193
					'defaults' => ['page' => 1],
				],
				[
					['post/index', ['page' => 1], false],
					['post/index', ['page' => '1abc', 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/-a'],
					['post/index', ['page' => 2, 'tag' => 'a'], 'post/2-a'],
				],
			],
			[
Qiang Xue committed
194
				'optional param at the end',
Alexander Makarov committed
195
				[
Qiang Xue committed
196 197
					'pattern' => 'post/<tag>/<page:\d+>',
					'route' => 'post/index',
Alexander Makarov committed
198 199 200 201 202 203 204 205 206 207
					'defaults' => ['page' => 1],
				],
				[
					['post/index', ['page' => 1], false],
					['post/index', ['page' => '1abc', 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/a'],
					['post/index', ['page' => 2, 'tag' => 'a'], 'post/a/2'],
				],
			],
			[
Qiang Xue committed
208
				'consecutive optional params',
Alexander Makarov committed
209
				[
Qiang Xue committed
210 211
					'pattern' => 'post/<page:\d+>/<tag>',
					'route' => 'post/index',
Alexander Makarov committed
212 213 214 215 216 217 218 219 220 221 222 223
					'defaults' => ['page' => 1, 'tag' => 'a'],
				],
				[
					['post/index', ['page' => 1], false],
					['post/index', ['page' => '1abc', 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post'],
					['post/index', ['page' => 2, 'tag' => 'a'], 'post/2'],
					['post/index', ['page' => 1, 'tag' => 'b'], 'post/b'],
					['post/index', ['page' => 2, 'tag' => 'b'], 'post/2/b'],
				],
			],
			[
Qiang Xue committed
224
				'consecutive optional params separated by dash',
Alexander Makarov committed
225
				[
Qiang Xue committed
226 227
					'pattern' => 'post/<page:\d+>-<tag>',
					'route' => 'post/index',
Alexander Makarov committed
228 229 230 231 232 233 234 235 236 237 238 239
					'defaults' => ['page' => 1, 'tag' => 'a'],
				],
				[
					['post/index', ['page' => 1], false],
					['post/index', ['page' => '1abc', 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a'], 'post/-'],
					['post/index', ['page' => 1, 'tag' => 'b'], 'post/-b'],
					['post/index', ['page' => 2, 'tag' => 'a'], 'post/2-'],
					['post/index', ['page' => 2, 'tag' => 'b'], 'post/2-b'],
				],
			],
			[
Qiang Xue committed
240
				'route has parameters',
Alexander Makarov committed
241
				[
Qiang Xue committed
242 243
					'pattern' => '<controller>/<action>',
					'route' => '<controller>/<action>',
Alexander Makarov committed
244 245 246 247 248 249 250 251
					'defaults' => [],
				],
				[
					['post/index', ['page' => 1], 'post/index?page=1'],
					['module/post/index', [], false],
				],
			],
			[
Qiang Xue committed
252
				'route has parameters with regex',
Alexander Makarov committed
253
				[
Qiang Xue committed
254 255
					'pattern' => '<controller:post|comment>/<action>',
					'route' => '<controller>/<action>',
Alexander Makarov committed
256 257 258 259 260 261 262 263 264 265 266 267
					'defaults' => [],
				],
				[
					['post/index', ['page' => 1], 'post/index?page=1'],
					['comment/index', ['page' => 1], 'comment/index?page=1'],
					['test/index', ['page' => 1], false],
					['post', [], false],
					['module/post/index', [], false],
					['post/index', ['controller' => 'comment'], 'post/index?controller=comment'],
				],
			],
			[
Qiang Xue committed
268
				'route has default parameter',
Alexander Makarov committed
269
				[
Qiang Xue committed
270 271
					'pattern' => '<controller:post|comment>/<action>',
					'route' => '<controller>/<action>',
Alexander Makarov committed
272 273 274 275 276 277 278 279 280 281 282
					'defaults' => ['action' => 'index'],
				],
				[
					['post/view', ['page' => 1], 'post/view?page=1'],
					['comment/view', ['page' => 1], 'comment/view?page=1'],
					['test/view', ['page' => 1], false],
					['test/index', ['page' => 1], false],
					['post/index', ['page' => 1], 'post?page=1'],
				],
			],
			[
Qiang Xue committed
283
				'empty pattern with suffix',
Alexander Makarov committed
284
				[
Qiang Xue committed
285 286 287
					'pattern' => '',
					'route' => 'post/index',
					'suffix' => '.html',
Alexander Makarov committed
288 289 290 291 292 293 294 295
				],
				[
					['post/index', [], ''],
					['comment/index', [], false],
					['post/index', ['page' => 1], '?page=1'],
				],
			],
			[
Qiang Xue committed
296
				'regular pattern with suffix',
Alexander Makarov committed
297
				[
Qiang Xue committed
298 299 300
					'pattern' => 'posts',
					'route' => 'post/index',
					'suffix' => '.html',
Alexander Makarov committed
301 302 303 304 305 306 307 308
				],
				[
					['post/index', [], 'posts.html'],
					['comment/index', [], false],
					['post/index', ['page' => 1], 'posts.html?page=1'],
				],
			],
			[
Qiang Xue committed
309
				'empty pattern with slash suffix',
Alexander Makarov committed
310
				[
Qiang Xue committed
311 312 313
					'pattern' => '',
					'route' => 'post/index',
					'suffix' => '/',
Alexander Makarov committed
314 315 316 317 318 319 320 321
				],
				[
					['post/index', [], ''],
					['comment/index', [], false],
					['post/index', ['page' => 1], '?page=1'],
				],
			],
			[
Qiang Xue committed
322
				'regular pattern with slash suffix',
Alexander Makarov committed
323
				[
Qiang Xue committed
324 325 326
					'pattern' => 'posts',
					'route' => 'post/index',
					'suffix' => '/',
Alexander Makarov committed
327 328 329 330 331 332 333 334
				],
				[
					['post/index', [], 'posts/'],
					['comment/index', [], false],
					['post/index', ['page' => 1], 'posts/?page=1'],
				],
			],
			[
335
				'with host info',
Alexander Makarov committed
336
				[
Qiang Xue committed
337
					'pattern' => 'post/<page:\d+>/<tag>',
338
					'route' => 'post/index',
Alexander Makarov committed
339
					'defaults' => ['page' => 1],
Qiang Xue committed
340
					'host' => 'http://<lang:en|fr>.example.com',
Alexander Makarov committed
341 342 343 344 345 346 347
				],
				[
					['post/index', ['page' => 1, 'tag' => 'a'], false],
					['post/index', ['page' => 1, 'tag' => 'a', 'lang' => 'en'], 'http://en.example.com/post/a'],
				],
			],
		];
Qiang Xue committed
348 349
	}

Qiang Xue committed
350
	protected function getTestsForParseRequest()
Qiang Xue committed
351 352 353 354 355 356 357 358
	{
		// structure of each test
		//   message for the test
		//   config for the URL rule
		//   list of inputs and outputs
		//     pathInfo
		//     expected route, or false if the rule doesn't apply
		//     expected params, or not set if empty
Alexander Makarov committed
359 360
		return [
			[
Qiang Xue committed
361
				'empty pattern',
Alexander Makarov committed
362
				[
Qiang Xue committed
363 364
					'pattern' => '',
					'route' => 'post/index',
Alexander Makarov committed
365 366 367 368 369 370 371
				],
				[
					['', 'post/index'],
					['a', false],
				],
			],
			[
Qiang Xue committed
372
				'without param',
Alexander Makarov committed
373
				[
Qiang Xue committed
374 375
					'pattern' => 'posts',
					'route' => 'post/index',
Alexander Makarov committed
376 377 378 379 380 381 382
				],
				[
					['posts', 'post/index'],
					['a', false],
				],
			],
			[
383
				'with dot', // https://github.com/yiisoft/yii/issues/2945
Alexander Makarov committed
384
				[
385 386
					'pattern' => 'posts.html',
					'route' => 'post/index',
Alexander Makarov committed
387 388 389 390 391 392 393
				],
				[
					['posts.html', 'post/index'],
					['postsahtml', false],
				],
			],
			[
Qiang Xue committed
394
				'creation only',
Alexander Makarov committed
395
				[
Qiang Xue committed
396 397 398
					'pattern' => 'posts',
					'route' => 'post/index',
					'mode' => UrlRule::CREATION_ONLY,
Alexander Makarov committed
399 400 401 402 403 404
				],
				[
					['posts', false],
				],
			],
			[
Qiang Xue committed
405
				'with param',
Alexander Makarov committed
406
				[
Qiang Xue committed
407 408
					'pattern' => 'post/<page>',
					'route' => 'post/index',
Alexander Makarov committed
409 410 411 412 413 414 415 416 417
				],
				[
					['post/1', 'post/index', ['page' => '1']],
					['post/a', 'post/index', ['page' => 'a']],
					['post', false],
					['posts', false],
				],
			],
			[
Qiang Xue committed
418
				'with param requirement',
Alexander Makarov committed
419
				[
Qiang Xue committed
420 421
					'pattern' => 'post/<page:\d+>',
					'route' => 'post/index',
Alexander Makarov committed
422 423 424 425 426 427 428 429
				],
				[
					['post/1', 'post/index', ['page' => '1']],
					['post/a', false],
					['post/1/a', false],
				],
			],
			[
Qiang Xue committed
430
				'with multiple params',
Alexander Makarov committed
431
				[
Qiang Xue committed
432 433
					'pattern' => 'post/<page:\d+>-<tag>',
					'route' => 'post/index',
Alexander Makarov committed
434 435 436 437 438 439 440 441 442
				],
				[
					['post/1-a', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/a', false],
					['post/1', false],
					['post/1/a', false],
				],
			],
			[
Qiang Xue committed
443
				'with optional param',
Alexander Makarov committed
444
				[
Qiang Xue committed
445 446
					'pattern' => 'post/<page:\d+>/<tag>',
					'route' => 'post/index',
Alexander Makarov committed
447 448 449 450 451 452 453 454 455 456
					'defaults' => ['page' => 1],
				],
				[
					['post/1/a', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/2/a', 'post/index', ['page' => '2', 'tag' => 'a']],
					['post/a', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/1', 'post/index', ['page' => '1', 'tag' => '1']],
				],
			],
			[
Qiang Xue committed
457
				'with optional param not in pattern',
Alexander Makarov committed
458
				[
Qiang Xue committed
459 460
					'pattern' => 'post/<tag>',
					'route' => 'post/index',
Alexander Makarov committed
461 462 463 464 465 466 467 468 469
					'defaults' => ['page' => 1],
				],
				[
					['post/a', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/1', 'post/index', ['page' => '1', 'tag' => '1']],
					['post', false],
				],
			],
			[
Qiang Xue committed
470
				'multiple optional params',
Alexander Makarov committed
471
				[
Qiang Xue committed
472 473
					'pattern' => 'post/<page:\d+>/<tag>/<sort:yes|no>',
					'route' => 'post/index',
Alexander Makarov committed
474 475 476 477 478 479 480 481 482 483 484 485 486
					'defaults' => ['page' => 1, 'sort' => 'yes'],
				],
				[
					['post/1/a/yes', 'post/index', ['page' => '1', 'tag' => 'a', 'sort' => 'yes']],
					['post/1/a/no', 'post/index', ['page' => '1', 'tag' => 'a', 'sort' => 'no']],
					['post/2/a/no', 'post/index', ['page' => '2', 'tag' => 'a', 'sort' => 'no']],
					['post/2/a', 'post/index', ['page' => '2', 'tag' => 'a', 'sort' => 'yes']],
					['post/a/no', 'post/index', ['page' => '1', 'tag' => 'a', 'sort' => 'no']],
					['post/a', 'post/index', ['page' => '1', 'tag' => 'a', 'sort' => 'yes']],
					['post', false],
				],
			],
			[
Qiang Xue committed
487
				'optional param and required param separated by dashes',
Alexander Makarov committed
488
				[
Qiang Xue committed
489 490
					'pattern' => 'post/<page:\d+>-<tag>',
					'route' => 'post/index',
Alexander Makarov committed
491 492 493 494 495 496 497 498 499 500 501
					'defaults' => ['page' => 1],
				],
				[
					['post/1-a', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/2-a', 'post/index', ['page' => '2', 'tag' => 'a']],
					['post/-a', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/a', false],
					['post-a', false],
				],
			],
			[
Qiang Xue committed
502
				'optional param at the end',
Alexander Makarov committed
503
				[
Qiang Xue committed
504 505
					'pattern' => 'post/<tag>/<page:\d+>',
					'route' => 'post/index',
Alexander Makarov committed
506 507 508 509 510 511 512 513 514 515 516
					'defaults' => ['page' => 1],
				],
				[
					['post/a/1', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/a/2', 'post/index', ['page' => '2', 'tag' => 'a']],
					['post/a', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/2', 'post/index', ['page' => '1', 'tag' => '2']],
					['post', false],
				],
			],
			[
Qiang Xue committed
517
				'consecutive optional params',
Alexander Makarov committed
518
				[
Qiang Xue committed
519 520
					'pattern' => 'post/<page:\d+>/<tag>',
					'route' => 'post/index',
Alexander Makarov committed
521 522 523 524 525 526 527 528 529 530 531
					'defaults' => ['page' => 1, 'tag' => 'a'],
				],
				[
					['post/2/b', 'post/index', ['page' => '2', 'tag' => 'b']],
					['post/2', 'post/index', ['page' => '2', 'tag' => 'a']],
					['post', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post/b', 'post/index', ['page' => '1', 'tag' => 'b']],
					['post//b', false],
				],
			],
			[
Qiang Xue committed
532
				'consecutive optional params separated by dash',
Alexander Makarov committed
533
				[
Qiang Xue committed
534 535
					'pattern' => 'post/<page:\d+>-<tag>',
					'route' => 'post/index',
Alexander Makarov committed
536 537 538 539 540 541 542 543 544 545 546
					'defaults' => ['page' => 1, 'tag' => 'a'],
				],
				[
					['post/2-b', 'post/index', ['page' => '2', 'tag' => 'b']],
					['post/2-', 'post/index', ['page' => '2', 'tag' => 'a']],
					['post/-b', 'post/index', ['page' => '1', 'tag' => 'b']],
					['post/-', 'post/index', ['page' => '1', 'tag' => 'a']],
					['post', false],
				],
			],
			[
Qiang Xue committed
547
				'route has parameters',
Alexander Makarov committed
548
				[
Qiang Xue committed
549 550
					'pattern' => '<controller>/<action>',
					'route' => '<controller>/<action>',
Alexander Makarov committed
551 552 553 554 555 556 557 558
					'defaults' => [],
				],
				[
					['post/index', 'post/index'],
					['module/post/index', false],
				],
			],
			[
Qiang Xue committed
559
				'route has parameters with regex',
Alexander Makarov committed
560
				[
Qiang Xue committed
561 562
					'pattern' => '<controller:post|comment>/<action>',
					'route' => '<controller>/<action>',
Alexander Makarov committed
563 564 565 566 567 568 569 570 571 572 573
					'defaults' => [],
				],
				[
					['post/index', 'post/index'],
					['comment/index', 'comment/index'],
					['test/index', false],
					['post', false],
					['module/post/index', false],
				],
			],
			[
Qiang Xue committed
574
				'route has default parameter',
Alexander Makarov committed
575
				[
Qiang Xue committed
576 577
					'pattern' => '<controller:post|comment>/<action>',
					'route' => '<controller>/<action>',
Alexander Makarov committed
578 579 580 581 582 583 584 585 586 587 588 589 590
					'defaults' => ['action' => 'index'],
				],
				[
					['post/view', 'post/view'],
					['comment/view', 'comment/view'],
					['test/view', false],
					['post', 'post/index'],
					['posts', false],
					['test', false],
					['index', false],
				],
			],
			[
Qiang Xue committed
591
				'empty pattern with suffix',
Alexander Makarov committed
592
				[
Qiang Xue committed
593 594 595
					'pattern' => '',
					'route' => 'post/index',
					'suffix' => '.html',
Alexander Makarov committed
596 597 598 599 600 601 602 603
				],
				[
					['', 'post/index'],
					['.html', false],
					['a.html', false],
				],
			],
			[
Qiang Xue committed
604
				'regular pattern with suffix',
Alexander Makarov committed
605
				[
Qiang Xue committed
606 607 608
					'pattern' => 'posts',
					'route' => 'post/index',
					'suffix' => '.html',
Alexander Makarov committed
609 610 611 612 613 614 615 616 617 618
				],
				[
					['posts.html', 'post/index'],
					['posts', false],
					['posts.HTML', false],
					['a.html', false],
					['a', false],
				],
			],
			[
Qiang Xue committed
619
				'empty pattern with slash suffix',
Alexander Makarov committed
620
				[
Qiang Xue committed
621 622 623
					'pattern' => '',
					'route' => 'post/index',
					'suffix' => '/',
Alexander Makarov committed
624 625 626 627 628 629 630
				],
				[
					['', 'post/index'],
					['a', false],
				],
			],
			[
Qiang Xue committed
631
				'regular pattern with slash suffix',
Alexander Makarov committed
632
				[
Qiang Xue committed
633 634 635
					'pattern' => 'posts',
					'route' => 'post/index',
					'suffix' => '/',
Alexander Makarov committed
636 637 638 639 640 641 642 643
				],
				[
					['posts/', 'post/index'],
					['posts', false],
					['a', false],
				],
			],
			[
644
				'with host info',
Alexander Makarov committed
645
				[
Qiang Xue committed
646
					'pattern' => 'post/<page:\d+>',
647
					'route' => 'post/index',
Qiang Xue committed
648
					'host' => 'http://<lang:en|fr>.example.com',
Alexander Makarov committed
649 650 651 652 653 654 655 656
				],
				[
					['post/1', 'post/index', ['page' => '1', 'lang' => 'en']],
					['post/a', false],
					['post/1/a', false],
				],
			],
		];
Qiang Xue committed
657 658
	}
}