*/ private array $tempFiles = []; /** @var list */ private array $tempDirs = []; protected function tearDown(): void { foreach ($this->tempFiles as $file) { @unlink($file); } foreach ($this->tempDirs as $dir) { @rmdir($dir); } } public function testLoadsCoreRoutesAndPublicPathsFromConfigFile(): void { $routesFile = $this->createRoutesFile([ ['path' => 'login', 'target' => 'auth/login', 'public' => true], ['path' => 'profile', 'target' => 'account/profile', 'public' => false], ]); $catalog = RouteCatalog::fromConfigFile($routesFile); self::assertSame( [ ['path' => 'login', 'target' => 'auth/login', 'public' => true], ['path' => 'profile', 'target' => 'account/profile', 'public' => false], ], $catalog->coreRoutes() ); self::assertSame(['auth/login', 'login'], $catalog->corePublicPaths()); } public function testThrowsWhenRouteConfigDoesNotReturnArray(): void { $routesFile = $this->createRawConfigFile("expectException(RuntimeException::class); $this->expectExceptionMessage('must return an array'); RouteCatalog::fromConfigFile($routesFile); } public function testThrowsForInvalidRouteShape(): void { $routesFile = $this->createRoutesFile([ ['path' => 'login'], ]); $this->expectException(RuntimeException::class); $this->expectExceptionMessage('Invalid route definition'); RouteCatalog::fromConfigFile($routesFile); } /** * @param list> $routes */ private function createRoutesFile(array $routes): string { return $this->createRawConfigFile( 'tempFiles[] = $file; $this->tempDirs[] = $dir; return $file; } }