assertChangelogOutputIsValid(__DIR__ . '/../../test_data/changelog/CHANGELOG-5.2.md');
}
#[RequiresPhpExtension('zlib')]
public function testWithCompressedFile(): void
{
$this->assertChangelogOutputIsValid(__DIR__ . '/../../test_data/changelog/CHANGELOG-5.2.md.gz');
}
private function assertChangelogOutputIsValid(string $changelogPath): void
{
$config = self::createStub(Config::class);
$config->method('getChangeLogFilePath')->willReturn($changelogPath);
$request = ServerRequestFactory::create()->createServerRequest('GET', 'https://example.com/');
$responseRenderer = new ResponseRenderer();
$template = new Template();
$controller = new ChangeLogController($responseRenderer, $config, ResponseFactory::create(), $template);
$response = $controller($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
self::assertSame(['text/html; charset=utf-8'], $response->getHeader('Content-Type'));
// phpcs:disable Generic.Files.LineLength.TooLong
$changelog = <<<'HTML'
Changes in phpMyAdmin 5.2
All notable changes of the phpMyAdmin 5.2 release series are documented in this file following the Keep a Changelog format.
5.2.2 (not yet released)
Fixed
* #17522: Fix case where the routes cache file is invalid
Security
* Upgrade slim/psr7 to 1.4.1 for CVE-2023-30536 - GHSA-q2qj-628g-vhfw
5.2.1 2023-02-07
Added
* #17519: Fix Export pages not working in certain conditions
* #17496: Fix error in table operation page when partitions are broken
Changed
* #17519: Fix Export pages not working in certain conditions
* #17496: Fix error in table operation page when partitions are broken
Deprecated
* #17519: Fix Export pages not working in certain conditions
* #17496: Fix error in table operation page when partitions are broken
Removed
* #17519: Fix Export pages not working in certain conditions
* #17496: Fix error in table operation page when partitions are broken
Fixed
* #17519: Fix Export pages not working in certain conditions
* #17496: Fix error in table operation page when partitions are broken
* #16418: Fix FAQ 1.44 about manually removing vendor folders
Security
* Fix an XSS attack through the drag-and-drop upload feature (PMASA-2023-01)
HTML;
// phpcs:enable
$expected = $template->render('changelog', ['changelog' => $changelog]);
self::assertSame($expected, (string) $response->getBody());
}
public function testWithInvalidFile(): void
{
$config = self::createStub(Config::class);
$config->method('getChangeLogFilePath')->willReturn(__DIR__ . '/../../test_data/changelog/InvalidChangeLog');
$request = ServerRequestFactory::create()->createServerRequest('GET', 'https://example.com/');
$responseRenderer = new ResponseRenderer();
$controller = new ChangeLogController($responseRenderer, $config, ResponseFactory::create(), new Template());
$response = $controller($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
self::assertSame(['text/html; charset=utf-8'], $response->getHeader('Content-Type'));
self::assertSame(
'The InvalidChangeLog file is not available on this system, please visit'
. ' phpmyadmin.net for more information.',
(string) $response->getBody(),
);
}
}