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