/** * builds the filename where the test is generated to * * @param string $filename * @return string */ private function getFilenameOfTestByOriginalFilename($filename) { $targetParts = explode(DIRECTORY_SEPARATOR, $this->configuration->getTargetDirectory()); $directory = array(); foreach (explode(DIRECTORY_SEPARATOR, $filename) as $key => $path) { if ($targetParts[$key] != $path) { $directory[] = $path; } else { } } //remove first directory, would be in the most cases src or classes or something like this... array_shift($directory); $f = $this->configuration->getTargetDirectory() . DIRECTORY_SEPARATOR . "unit" . DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $directory); if (self::endsWith($f, ".class.php")) { $f = str_replace(array(".class.php"), array("Test.class.php"), $f); } else { $f = str_replace(array(".php"), array("Test.php"), $f); } return $f; }
/** * index files for given configuration from file system and create a testable collection of files * * @param \PhpUnitTestGenerator\Configuration\ConfigurationInterface $configuration * @return \PhpUnitTestGenerator\Testable\Collection */ public function indexFilesFromConfiguration(\PhpUnitTestGenerator\Configuration\ConfigurationInterface $configuration) { return new \PhpUnitTestGenerator\Testable\Collection($configuration, $this->indexFilesFromSource($configuration->getSourceDirectory())); }