public function testGetFiles() { $this->assertEquals(['a.txt', 'b.txt'], Filesystem::getFiles(self::TEST_DIRECTORY)); }
/** * Attempts to find an XML and an XSL filename in the given folder and adds an error if it cannot find them. * @param $fromWhere string directory from where to load the files * @param $xmlFile string The found XML filename. * @param $xslFile string The found XSL filename. */ private function loadFiles($fromWhere, &$xmlFile, &$xslFile) { $xmlFile = false; $xslFile = false; $files = \asm\utils\Filesystem::getFiles($fromWhere); foreach ($files as $file) { if (Utils::endsWith(strtolower($file), ".xml")) { if ($xmlFile === false) { $xmlFile = \asm\utils\Filesystem::combinePaths($fromWhere, $file); } else { $this->addError("There are two or more .xml files in your submission. There must only be one."); } } if (Utils::endsWith(strtolower($file), ".xsl")) { if ($xslFile === false) { $xslFile = \asm\utils\Filesystem::combinePaths($fromWhere, $file); } else { $this->addError("There are two or more .xsl files in your submission. There must only be one."); } } } if ($xmlFile === false) { $this->addError("Your submission must contain an XML file ending with '.xml'."); } if ($xslFile === false) { $this->addError("Your submission must contain an XSL file ending with '.xsl'."); } }