method('getChangeLogFilePath')->willReturn(TEST_PATH . 'tests/test_data/changelog/ChangeLog'); $request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/'); $responseRenderer = new ResponseRenderer(); $template = new Template(); $controller = new ChangeLogController($responseRenderer, $config); $controller($request); self::assertTrue($responseRenderer->isDisabled()); $response = $responseRenderer->getResponse(); self::assertSame(['text/html; charset=utf-8'], $response->getHeader('Content-Type')); // phpcs:disable Generic.Files.LineLength.TooLong $changelog = <<<'HTML' phpMyAdmin - ChangeLog ====================== 5.2.2 (not yet released) - issue #17522 Fix case where the routes cache file is invalid - issue Upgrade slim/psr7 to 1.4.1 for CVE-2023-30536 - GHSA-q2qj-628g-vhfw 5.2.1 (2023-02-07) - issue #16418 Fix FAQ 1.44 about manually removing vendor folders - issue [security] Fix an XSS attack through the drag-and-drop upload feature (PMASA-2023-01) --- Older ChangeLogs can be found on our project website --- https://www.phpmyadmin.net/old-stuff/ChangeLogs/ HTML; // phpcs:enable $expected = $template->render('changelog', ['changelog' => $changelog]); self::assertSame($expected, $responseRenderer->getHTMLResult()); } #[RequiresPhpExtension('zlib')] public function testWithCompressedFile(): void { $config = self::createStub(Config::class); $config->method('getChangeLogFilePath')->willReturn(TEST_PATH . 'tests/test_data/changelog/ChangeLog.gz'); $request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/'); $responseRenderer = new ResponseRenderer(); $controller = new ChangeLogController($responseRenderer, $config); $controller($request); self::assertStringContainsString( '- ' . 'issue #16418 Fix ' . 'FAQ 1.44 about manually removing vendor folders', $responseRenderer->getHTMLResult(), ); } public function testWithInvalidFile(): void { $config = self::createStub(Config::class); $config->method('getChangeLogFilePath')->willReturn(TEST_PATH . 'tests/test_data/changelog/InvalidChangeLog'); $request = ServerRequestFactory::create()->createServerRequest('GET', 'http://example.com/'); $responseRenderer = new ResponseRenderer(); $controller = new ChangeLogController($responseRenderer, $config); $controller($request); self::assertSame('', $responseRenderer->getHTMLResult()); self::assertSame( 'The InvalidChangeLog file is not available on this system, please visit' . ' phpmyadmin.net for more information.', self::getActualOutputForAssertion(), ); } }