/** * Run the test suite with the current directory. * * @param boolean $printDir print directory information */ private function runTests($printDir = true) { $dir = ''; if ($printDir) { $dir = "on directory <info>{$this->dir}</info>"; } $this->output->writeln("Running Extension Pre Validator {$dir}."); $runner = new TestRunner($this->output, $this->dir, $this->debug); if ($this->debug) { $this->output->writelnIfDebug("tests to run:"); foreach ($runner->tests as $t => $test) { $this->output->writelnIfDebug("<info>{$test}</info>"); } } $runner->runTests(); }
/** * Attempts to load a file based on extension. * * In case of plaintext files, contents are also checked to see if it isn't a php file. * * @param $fileName * @param $extension * * @return BinaryFile|ComposerFile|CssFile|HTMLFile|JavascriptFile|JsonFile|PHPFile|PlainFile|XmlFile|YmlFile|ImageFile|null */ private function tryLoadFile($fileName, $extension) { $this->output->writelnIfDebug("<info>Attempting to load {$fileName} with extension {$extension}</info>"); $this->loadError = false; switch (strtolower($extension)) { case 'php': // First, check if this file is a lang file. $file = basename($fileName); $dir = str_replace($file, '', $fileName); $dir = str_replace($this->basedir, '', $fileName); $dir = explode('/', $dir); if (trim(strtolower($dir[0])) == 'language') { return new LangFile($this->debug, $fileName, $this->rundir); } return new PHPFile($this->debug, $fileName, $this->rundir); case 'html': case 'htm': return new HTMLFile($this->debug, $fileName, $this->rundir); case 'json': if (strtolower(basename($fileName)) == 'composer.json') { return new ComposerFile($this->debug, $fileName, $this->rundir); } else { return new JsonFile($this->debug, $fileName, $this->rundir); } case 'yml': if (strtolower(basename($fileName)) == 'services.yml') { return new ServiceFile($this->debug, $fileName, $this->rundir); } if (strtolower(basename($fileName)) == 'routing.yml') { return new RoutingFile($this->debug, $fileName, $this->rundir); } return new YmlFile($this->debug, $fileName, $this->rundir); case 'txt': case 'md': case 'htaccess': case 'gitattributes': case 'gitignore': case 'map': case 'sh': // Decide if we want a special file type for shell files! return new PlainFile($this->debug, $fileName, $this->rundir); case 'xml': return new XmlFile($this->debug, $fileName, $this->rundir); case 'js': return new JavascriptFile($this->debug, $fileName, $this->rundir); case 'css': return new CssFile($this->debug, $fileName, $this->rundir); case 'gif': case 'png': case 'jpg': case 'jpeg': case 'svg': return new ImageFile($this->debug, $fileName, $this->rundir); case 'swf': $this->output->addMessage(Output::NOTICE, sprintf("Found an SWF file (%s), please make sure to include the source files for it, as required by the GPL.", basename($fileName))); return new BinaryFile($this->debug, $fileName, $this->rundir); case 'ds_store': $this->output->addMessage(Output::ERROR, sprintf("Found an OS X specific file at %s, please make sure to remove it prior to submission.", $fileName)); return new BinaryFile($this->debug, $fileName, $this->rundir); case 'lock': return new LockFile($this->debug, $fileName, $this->rundir); default: $file = basename($fileName); $this->output->addMessage(Output::WARNING, "Can't detect the file type for {$file}, handling it as a binary file."); return new BinaryFile($this->debug, $fileName, $this->rundir); } }