fileListing = new FileListing();
}
public function testGetDirContent(): void
{
self::assertFalse($this->fileListing->getDirContent('nonexistent directory'));
$fixturesDir = __DIR__ . '/_data/file_listing';
$dirContent = $this->fileListing->getDirContent($fixturesDir);
if (is_bool($dirContent)) {
$dirContent = [];
}
self::assertSame(
['one.txt', 'two.md'],
array_values($dirContent),
);
}
public function testGetFileSelectOptions(): void
{
$fixturesDir = __DIR__ . '/_data/file_listing';
self::assertFalse($this->fileListing->getFileSelectOptions('nonexistent directory'));
$expectedHtmlWithoutActive = ' ' . "\n"
. ' ' . "\n";
self::assertSame(
$expectedHtmlWithoutActive,
$this->fileListing->getFileSelectOptions($fixturesDir),
);
$expectedHtmlWithActive = ' ' . "\n"
. ' ' . "\n";
self::assertSame(
$expectedHtmlWithActive,
$this->fileListing->getFileSelectOptions($fixturesDir, '', 'two.md'),
);
$expectedFilteredHtml = ' ' . "\n";
self::assertSame(
$expectedFilteredHtml,
$this->fileListing->getFileSelectOptions($fixturesDir, '/.*\.txt/'),
);
}
public function testSupportedDecompressionsEmptyList(): void
{
$config = Config::getInstance();
$config->set('ZipDump', false);
$config->set('GZipDump', false);
$config->set('BZipDump', false);
self::assertEmpty($this->fileListing->supportedDecompressions());
}
#[RequiresPhpExtension('bz2')]
public function testSupportedDecompressionsFull(): void
{
self::assertSame('gz|bz2|zip', $this->fileListing->supportedDecompressions());
}
public function testSupportedDecompressionsPartial(): void
{
$extensionString = 'gz';
if (extension_loaded('bz2')) {
$extensionString .= '|bz2';
}
$extensionString .= '|zip';
self::assertSame($extensionString, $this->fileListing->supportedDecompressions());
}
}