private function load_tests(RecursiveDirectoryIterator $dir) { while ($dir->valid()) { $current = $dir->current(); if ($dir->isFile() && preg_match("/(.)Test\\.php\$/", $current->getFilename(), $matches)) { // XXX: handle errors include $current->getPathname(); $x = explode('.', $current->getFilename()); $class = $x[0]; $rclass = new ReflectionClass($class); if ($rclass->getParentClass()->getName() == 'UnitTest') { $this->cases[] = $rclass; } } elseif ($dir->hasChildren() && preg_match("/^\\./", $current->getFilename(), $matches) == 0) { $this->load_tests($dir->getChildren()); } $dir->next(); } }
/** * Recursive directory function. * * @param RecursiveDirectoryIterator $iterator */ protected function _recurseDirectory($iterator) { while ($iterator->valid()) { if ($iterator->isDir() && !$iterator->isDot()) { if ($iterator->hasChildren()) { $this->_recurseDirectory($iterator->getChildren()); } } elseif ($iterator->isFile()) { $path = $iterator->getPath() . '/' . $iterator->getFilename(); $pathinfo = pathinfo($path); if ($this->_isPhpFile($path)) { $this->addFile($path); } } $iterator->next(); } }
} mysql_connection_select(DATABASE); // set parameter defaults $formImportDir = @$_REQUEST['formImportDir']; // outName returns the hml direct. $resourceUriRoot = @$_REQUEST['resourceUriRoot']; // URI prefix for the resources upload with forms. //if no style given then try default, if default doesn't exist we our put raw xml $importData = array(); $info = new SplFileInfo($formImportDir); $i = 0; $xmlForms = array("form" => array(), "resource" => array()); if ($info->isDir()) { $iterator = new RecursiveDirectoryIterator($formImportDir); while ($iterator->valid()) { if ($iterator->isFile()) { $ext = pathinfo($iterator->getPathname(), PATHINFO_EXTENSION); if ($ext == "xml") { // echo $prefix,$j," import ",$dirIterator->getPathname(), "<br>\n"; $xmlForms["form"][$iterator->getFilename()] = $iterator->getPathname(); } else { $filepath = preg_replace("/" . preg_replace("/\\//", "\\\\/", HEURIST_UPLOAD_DIR) . "/", "/", $iterator->getPathname()); // echo $prefix,$j," resource ".$dirIterator->getFilename()." has path ".$filepath, "<br>\n"; $xmlForms["resource"][$iterator->getFilename()] = $filepath; } } else { if ($iterator->isDir() && $iterator->hasChildren(false)) { // echo $i,pathinfo($iterator->getPathname(),PATHINFO_FILENAME), "<br>\n"; processChildDir($iterator->getChildren(), $i . "-"); } }
/** * * Recursively iterates through a directory looking for class files. * * Skips CVS directories, and all files and dirs not starting with * a capital letter (such as dot-files). * * @param RecursiveDirectoryIterator $iter Directory iterator. * * @return void * */ protected function _fetch(RecursiveDirectoryIterator $iter) { for ($iter->rewind(); $iter->valid(); $iter->next()) { // preliminaries $path = $iter->current()->getPathname(); $file = basename($path); $capital = ctype_alpha($file[0]) && $file == ucfirst($file); $phpfile = strripos($file, '.php'); // check for valid class files if ($iter->isDot() || !$capital) { // skip dot-files (including dot-file directories), as // well as files/dirs not starting with a capital letter continue; } elseif ($iter->isDir() && $file == 'CVS') { // skip CVS directories continue; } elseif ($iter->isDir() && $iter->hasChildren()) { // descend into child directories $this->_fetch($iter->getChildren()); } elseif ($iter->isFile() && $phpfile) { // map the .php file to a class name $len = strlen($this->_base); $class = substr($path, $len, -4); // drops .php $class = str_replace(DIRECTORY_SEPARATOR, '_', $class); $this->_map[$class] = $path; } } }