1
0
mirror of https://github.com/dannyvankooten/AltoRouter.git synced 2025-08-04 15:37:45 +02:00

add test for #241

This commit is contained in:
Danny van Kooten
2019-11-23 11:35:40 +01:00
parent a51c74793a
commit a80bb36f11

View File

@@ -142,10 +142,10 @@ class AltoRouterTest extends PHPUnit\Framework\TestCase
*/ */
public function testSetBasePath() public function testSetBasePath()
{ {
$basePath = $this->router->setBasePath('/some/path'); $this->router->setBasePath('/some/path');
$this->assertEquals('/some/path', $this->router->getBasePath()); $this->assertEquals('/some/path', $this->router->getBasePath());
$basePath = $this->router->setBasePath('/some/path'); $this->router->setBasePath('/some/path');
$this->assertEquals('/some/path', $this->router->getBasePath()); $this->assertEquals('/some/path', $this->router->getBasePath());
} }
@@ -519,6 +519,20 @@ class AltoRouterTest extends PHPUnit\Framework\TestCase
$this->assertFalse($this->router->match('/﷽‎', 'GET')); $this->assertFalse($this->router->match('/﷽‎', 'GET'));
} }
public function testMatchWithSlashBeforeOptionalPart()
{
$this->router->map('GET', '/archives/[lmin:category]?', 'Article#archives');
$expected = [
'target' => 'Article#archives',
'params' => [],
'name' => null
];
$this->assertEquals($expected, $this->router->match('/archives/', 'GET'));
$this->assertEquals($expected, $this->router->match('/archives', 'GET'));
}
/** /**
* @covers AltoRouter::addMatchTypes * @covers AltoRouter::addMatchTypes
*/ */