for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types = 1);
namespace Mezon\Router\Tests\Standart;
use Mezon\Router\Router;
use Mezon\Router\RouterInterface;
use Mezon\Router\Tests\Base\ExtractParametersTestClass;
use Mezon\Router\Tests\Base\BaseRouterUnitTestClass;
/**
*
* @psalm-suppress PropertyNotSetInConstructor
*/
class ExtractParametersUnitTest extends ExtractParametersTestClass
{
* {@inheritdoc}
* @see BaseRouterUnitTestClass::getRouter()
protected function getRouter(): RouterInterface
return new Router();
}
* Testing parameter extractor.
public function testValidRouteParameter(): void
$router = new Router();
$router->addRoute('/catalog/all/', function (string $route): string {
return $route;
});
$router->addRoute('/catalog/[i:cat_id]', function (string $route): string {
// first reading
/** @var string $result */
$result = $router->callRoute('/catalog/all/');
$this->assertEquals($result, 'catalog/all');
// second route
$result = $router->callRoute('/catalog/1024/');
$this->assertEquals($result, 'catalog/1024');
// reading regexp from cache in the _getRouteMatcherRegExPattern method
$router->warmCache();