|
|
@ -500,18 +500,36 @@ class RouterTest extends PHPUnit\Framework\TestCase
|
|
|
|
$this->assertEquals('/path1/123', $url);
|
|
|
|
$this->assertEquals('/path1/123', $url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasSimpleParamsWithNumber() {
|
|
|
|
|
|
|
|
$this->router->map('/path1/@id1', [$this, 'ok'], false, 'path1');
|
|
|
|
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id1' => 123]);
|
|
|
|
|
|
|
|
$this->assertEquals('/path1/123', $url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasSimpleOptionalParamsWithParam() {
|
|
|
|
public function testGetUrlByAliasSimpleOptionalParamsWithParam() {
|
|
|
|
$this->router->map('/path1(/@id)', [$this, 'ok'], false, 'path1');
|
|
|
|
$this->router->map('/path1(/@id)', [$this, 'ok'], false, 'path1');
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id' => 123]);
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id' => 123]);
|
|
|
|
$this->assertEquals('/path1/123', $url);
|
|
|
|
$this->assertEquals('/path1/123', $url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasSimpleOptionalParamsWithNumberWithParam() {
|
|
|
|
|
|
|
|
$this->router->map('/path1(/@id1)', [$this, 'ok'], false, 'path1');
|
|
|
|
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id1' => 123]);
|
|
|
|
|
|
|
|
$this->assertEquals('/path1/123', $url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasSimpleOptionalParamsNoParam() {
|
|
|
|
public function testGetUrlByAliasSimpleOptionalParamsNoParam() {
|
|
|
|
$this->router->map('/path1(/@id)', [$this, 'ok'], false, 'path1');
|
|
|
|
$this->router->map('/path1(/@id)', [$this, 'ok'], false, 'path1');
|
|
|
|
$url = $this->router->getUrlByAlias('path1');
|
|
|
|
$url = $this->router->getUrlByAlias('path1');
|
|
|
|
$this->assertEquals('/path1', $url);
|
|
|
|
$this->assertEquals('/path1', $url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasSimpleOptionalParamsWithNumberNoParam() {
|
|
|
|
|
|
|
|
$this->router->map('/path1(/@id1)', [$this, 'ok'], false, 'path1');
|
|
|
|
|
|
|
|
$url = $this->router->getUrlByAlias('path1');
|
|
|
|
|
|
|
|
$this->assertEquals('/path1', $url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasMultipleParams() {
|
|
|
|
public function testGetUrlByAliasMultipleParams() {
|
|
|
|
$this->router->map('/path1/@id/@name', [$this, 'ok'], false, 'path1');
|
|
|
|
$this->router->map('/path1/@id/@name', [$this, 'ok'], false, 'path1');
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id' => 123, 'name' => 'abc']);
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id' => 123, 'name' => 'abc']);
|
|
|
@ -524,6 +542,12 @@ class RouterTest extends PHPUnit\Framework\TestCase
|
|
|
|
$this->assertEquals('/path1/123/abc', $url);
|
|
|
|
$this->assertEquals('/path1/123/abc', $url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasMultipleComplexParamsWithNumbers() {
|
|
|
|
|
|
|
|
$this->router->map('/path1/@5id:[0-9]+/@n1ame:[a-zA-Z0-9]{5}', [$this, 'ok'], false, 'path1');
|
|
|
|
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['5id' => '123', 'n1ame' => 'abc']);
|
|
|
|
|
|
|
|
$this->assertEquals('/path1/123/abc', $url);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetUrlByAliasMultipleComplexOptionalParamsMissingOne() {
|
|
|
|
public function testGetUrlByAliasMultipleComplexOptionalParamsMissingOne() {
|
|
|
|
$this->router->map('/path1(/@id:[0-9]+(/@name(/@crazy:[a-z]{5})))', [$this, 'ok'], false, 'path1');
|
|
|
|
$this->router->map('/path1(/@id:[0-9]+(/@name(/@crazy:[a-z]{5})))', [$this, 'ok'], false, 'path1');
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id' => '123', 'name' => 'abc']);
|
|
|
|
$url = $this->router->getUrlByAlias('path1', ['id' => '123', 'name' => 'abc']);
|
|
|
|