/** * Provides test cases for testRepeatedIteratorUse() * * A test case consists of an AutoloaderFileIterator object which is configured * to search in a not empty class path. * * @see testRepeatedIteratorUse() * @return Array */ public function provideTestRepeatedIteratorUse() { AutoloaderTestHelper::deleteDirectory("testRepeatedIteratorUse"); $alTestHelper = new AutoloaderTestHelper($this); $alTestHelper->makeClass("A", "testRepeatedIteratorUse"); $alTestHelper->makeClass("B", "testRepeatedIteratorUse"); $alTestHelper->makeClass("C", "testRepeatedIteratorUse/C"); $alTestHelper->makeClass("D", "testRepeatedIteratorUse/D"); $alTestHelper->makeClass("E", "testRepeatedIteratorUse/D"); $alTestHelper->makeClass("F", "testRepeatedIteratorUse/D"); $alTestHelper->makeClass("G", "testRepeatedIteratorUse/D/G"); $alTestHelper->makeClass("H", "testRepeatedIteratorUse"); $autoloader = new Autoloader(AutoloaderTestHelper::getClassDirectory("testRepeatedIteratorUse")); $simpleIterator = new AutoloaderFileIterator_Simple(); $simpleIterator->setAutoloader($autoloader); $simpleCachedIterator = new AutoloaderFileIterator_SimpleCached(); $simpleCachedIterator->setAutoloader($autoloader); $priorityIterator = new AutoloaderFileIterator_PriorityList(); $priorityIterator->setAutoloader($autoloader); return array(array($simpleIterator, 1), array($simpleIterator, 3), array($simpleIterator, 0), array($simpleIterator), array($simpleIterator, 1), array($simpleIterator, 3), array($simpleIterator, 0), array($simpleCachedIterator, 1), array($simpleCachedIterator, 3), array($simpleCachedIterator, 0), array($simpleCachedIterator), array($simpleCachedIterator, 1), array($simpleCachedIterator, 3), array($simpleCachedIterator, 0), array($priorityIterator, 1), array($priorityIterator, 3), array($priorityIterator, 0), array($priorityIterator), array($priorityIterator, 1), array($priorityIterator, 3), array($priorityIterator, 0)); }
/** * Iterates through the class path with an AutoloaderFileIterator_Simple object. * The found paths are stored in the arrays $_preferedFiles and * $_unpreferedFiles. * * @see AutoloaderFileIterator_Simple * @return Array */ private function _initFileArrays() { if (!empty($this->_preferedFiles) || !empty($this->_unpreferedFiles)) { return; } $simpleIterator = new AutoloaderFileIterator_Simple(); $simpleIterator->setAutoloader($this->autoloader); $simpleIterator->skipFilesize = $this->skipFilesize; $simpleIterator->skipPatterns = $this->skipPatterns; $this->_preferedFiles = array(); $this->_unpreferedFiles = array(); foreach ($simpleIterator as $file) { foreach ($this->_preferedPatterns as $pattern) { if (preg_match($pattern, $file)) { $this->_preferedFiles[] = $file; continue 2; } } $this->_unpreferedFiles[] = $file; } }