. // }}} namespace App\Test\Core; use App\Core\Router\RouteLoader; use App\Core\Router\Router; use App\Util\GNUsocialTestCase; use ReflectionClass; use Symfony\Component\Routing\Route as SRoute; class RouterTest extends GNUsocialTestCase { public function testRouter() { parent::bootKernel(); $rl = new RouteLoader(); $rl->load('', null); // parameters ignored $rl->connect(id: 'test_route', uri_path: '/test/{id<\d+>}', target: []); $refl = (new ReflectionClass($rl))->getProperty('rc'); $refl->setAccessible(true); $routes = $refl->getValue($rl)->all(); static::assertIsArray($routes); static::assertInstanceOf(SRoute::class, $routes['test_route']); static::assertSame('/test/{id}', $routes['test_route']->getPath()); } public function testURLGen() { parent::bootKernel(); static::assertSame( expected: '/object/note/1337/attachment/42/thumbnail/big', actual: Router::url('note_attachment_thumbnail', [ 'note_id' => 1337, 'attachment_id' => 42, 'size' => 'big', ]), ); } }