/** * Generate common file body to execute all tests * * @param array $destinations List of destination file names. * @param string $destinationRoot Root path for destinations. * @return string A source code (text) of run-file. */ public function generateRunFile($destinations, $destinationRoot) { if (!is_array($destinations)) { return false; } $destinationRoot = realpath($destinationRoot); $body = Basic::replace($this->runFileHeaderTemplate, array("DATE" => date("Y.m.d H:i"), "GENERATOR_NAME" => get_class(), "RUN_DIR" => $destinationRoot)); foreach ($destinations as $file => $_) { $testStruct = SimpleCodeParser::parseCode(file_get_contents($file)); if (is_array($testStruct)) { foreach ($testStruct as $nameSpace) { if (is_array($nameSpace["classes"])) { foreach ($nameSpace["classes"] as $className => $value) { $testName = $className; $path = Files::getRelativePath(dirname($file), $destinationRoot); $fileName = "." . $path["relative"] . "/" . basename($file); $logName = "." . $path["relative"] . "/" . $testName; $body .= Basic::replace($this->runFileLineTemplate, array("TEST_TITLE" => $testName, "TEST_NAME" => $testName, "TEST_FILE" => $fileName, "TEST_LOG" => $logName, "PHPUNIT" => $this->phpUnitFile)); } } } } } return $body; }