package.xml0000664000175000017500000000721612435110546013064 0ustar theseertheseer DirectoryScanner pear.netpirates.net A recursive directory scanner and filter A recursive directory scanner and filter Arne Blankerts theseer arne@blankerts.de yes 2014-11-25 1.3.1 1.3.0 stable stable BSD License http://github.com/theseer/DirectoryScanner/tree 5.3.1 1.8.1 SPL fileinfo DirectoryScanner-1.3.1/TheSeer/DirectoryScanner/autoload.php0000664000175000017500000000157712435110546024025 0ustar theseertheseer '/directoryscanner.php', 'theseer\\directoryscanner\\exception' => '/directoryscanner.php', 'theseer\\directoryscanner\\filesonlyfilteriterator' => '/filesonlyfilter.php', 'theseer\\directoryscanner\\includeexcludefilteriterator' => '/includeexcludefilter.php', 'theseer\\directoryscanner\\phpfilteriterator' => '/phpfilter.php' ); } $cn = strtolower($class); if (isset($classes[$cn])) { require __DIR__ . $classes[$cn]; } } ); // @codeCoverageIgnoreEnd DirectoryScanner-1.3.1/TheSeer/DirectoryScanner/directoryscanner.php0000664000175000017500000002124712435110546025567 0ustar theseertheseer * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package DirectoryScanner * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License * @link http://github.com/theseer/DirectoryScanner */ namespace TheSeer\DirectoryScanner { /** * Recursive scanner for files on given filesystem path with the ability to filter * results based on include and exclude patterns * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @version Release: 1.3.1 */ class DirectoryScanner { /** * List of filter for include shell patterns * * @var Array */ protected $include = array(); /** * List of filter for exclude shell patterns * * @var Array */ protected $exclude = array(); /** * Flags to pass on to RecursiveDirectoryIterator on construction * * @var int */ protected $flags = 0; /** * Add a new pattern to the include array * * @param string $inc Pattern to add * * @return void */ public function addInclude($inc) { $this->include[] = $inc; } /** * set the include pattern array * * @param Array $inc Array of include pattern strings * * @return void */ public function setIncludes(array $inc = array()) { $this->include = $inc; } /** * get array of current include patterns * * @return Array */ public function getIncludes() { return $this->include; } public function setFlag($flag) { if (!$this->isValidFlag($flag)) { throw new Exception("Invalid flag specified", Exception::InvalidFlag); } $this->flags = $this->flags | $flag; } public function unsetFlag($flag) { if (!$this->isValidFlag($flag)) { throw new Exception("Invalid flag specified", Exception::InvalidFlag); } $this->flags = $this->flags & ~$flag; } /** * @param boolean $followSymlinks * * @deprecated Use setFlag / unsetFlag with \FilesystemIterator::FOLLOW_SYMLINKS * @return void */ public function setFollowSymlinks($followSymlinks) { if ($followSymlinks == true) { $this->setFlag(\FilesystemIterator::FOLLOW_SYMLINKS); return; } $this->unsetFlag(\FilesystemIterator::FOLLOW_SYMLINKS); } /** * Public function, so it can be tested properly * * @return bool */ public function isFollowSymlinks() { return ($this->flags & \FilesystemIterator::FOLLOW_SYMLINKS) == \FilesystemIterator::FOLLOW_SYMLINKS; } /** * Add a new pattern to the exclude array * * @param string $exc Pattern to add * * @return void */ public function addExclude($exc) { $this->exclude[] = $exc; } /** * set the exclude pattern array * * @param Array $exc Array of exclude pattern strings * * @return void */ public function setExcludes(array $exc = array()) { $this->exclude = $exc; } /** * get array of current exclude patterns * * @return Array */ public function getExcludes() { return $this->exclude; } /** * get an array of splFileObjects from given path matching the * include/exclude patterns * * @param string $path Path to work on * @param boolean $recursive Scan recursivly or not * * @return Array of splFileInfo Objects */ public function getFiles($path, $recursive = true) { $res = array(); foreach($this->getIterator($path, $recursive) as $entry) { $res[] = $entry; } return $res; } /** * Magic invoker method to use object in foreach-alike constructs as iterator, * delegating work to getIterator() method * * @see getIterator * * @param string $path Path to work on * @param boolean $recursive Scan recursivly or not * * @return \Iterator */ public function __invoke($path, $recursive = true) { return $this->getIterator($path, $recursive); } /** * Scan given directory for files, returning splFileObjects matching the include/exclude patterns * * @param string $path Path to work on * @param boolean $recursive Scan recursively or not * * @throws Exception * @return \Iterator */ public function getIterator($path, $recursive = true) { if (!file_exists($path)) { throw new Exception("Path '$path' does not exist.", Exception::NotFound); } if ($recursive) { $worker = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $path, $this->flags ) ); } else { $worker = new \DirectoryIterator($path); } $filter = new IncludeExcludeFilterIterator( new FilesOnlyFilterIterator($worker) ); $filter->setInclude( count($this->include) ? $this->include : array('*')); $filter->setExclude($this->exclude); return $filter; } protected function isValidFlag($flag) { return in_array($flag, array( \FilesystemIterator::CURRENT_AS_PATHNAME, \FilesystemIterator::CURRENT_AS_FILEINFO, \FilesystemIterator::CURRENT_AS_SELF, \FilesystemIterator::CURRENT_MODE_MASK, \FilesystemIterator::KEY_AS_PATHNAME, \FilesystemIterator::KEY_AS_FILENAME, \FilesystemIterator::FOLLOW_SYMLINKS, \FilesystemIterator::KEY_MODE_MASK, \FilesystemIterator::NEW_CURRENT_AND_KEY, \FilesystemIterator::SKIP_DOTS, \FilesystemIterator::UNIX_PATHS )); } } /** * DirectoryScanner Exception class * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class Exception extends \Exception { /** * Error constant for "notFound" condition * * @var integer */ const NotFound = 1; /** * Error condition for invalid flag passed to setFlag/unsetFlag method * * @var integer */ const InvalidFlag = 2; } } DirectoryScanner-1.3.1/TheSeer/DirectoryScanner/filesonlyfilter.php0000664000175000017500000000526012435110546025420 0ustar theseertheseer * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package DirectoryScanner * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\DirectoryScanner { /** * FilterIterator to accept on files from a directory iterator * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @version Release: 1.3.1 */ class FilesOnlyFilterIterator extends \FilterIterator { /** * FilterIterator Method to decide whether or not to include * the current item into the list * * @return boolean */ public function accept() { switch($this->current()->getType()) { case 'file': { return true; } case 'link': { return is_file(realpath($this->current()->getPathname())); } default: { return false; } } } } } DirectoryScanner-1.3.1/TheSeer/DirectoryScanner/includeexcludefilter.php0000664000175000017500000000713212435110546026411 0ustar theseertheseer * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package DirectoryScanner * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\DirectoryScanner { /** * FilterIterator to accept Items based on include/exclude conditions * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @version Release: 1.3.1 */ class IncludeExcludeFilterIterator extends \FilterIterator { /** * List of filter for include shell patterns * * @var Array */ protected $include; /** * List of filter for exclude shell patterns * * @var Array */ protected $exclude; /** * Set and by that overwrite the include filter array * * @param Array $inc Array of include pattern strings * * @return void */ public function setInclude(array $inc = array()) { $this->include = $inc; } /** * Set and by that overwrite the exclude filter array * * @param Array $exc Array of exclude pattern strings * * @return void */ public function setExclude(array $exc = array()) { $this->exclude = $exc; } /** * FilterIterator Method to decide whether or not to include * the current item into the list * * @return boolean */ public function accept() { $pathname = $this->current()->getPathname(); foreach($this->exclude as $out) { if (fnmatch($out, $pathname)) { return false; } } foreach($this->include as $in) { if (fnmatch($in, $pathname)) { return true; } } return false; } } } DirectoryScanner-1.3.1/TheSeer/DirectoryScanner/phpfilter.php0000664000175000017500000000472312435110546024206 0ustar theseertheseer * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\DirectoryScanner { /** * FilterIterator to accept only php source files based on content * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @version Release: 1.3.1 */ class PHPFilterIterator extends \FilterIterator { /** * FilterIterator Method to decide whether or not to include * the current item into the list * * @return boolean */ public function accept() { $finfo = new \finfo(FILEINFO_MIME); return strpos($finfo->file($this->current()->getPathname()), 'text/x-php') === 0; } } } DirectoryScanner-1.3.1/tests/_data/nested/1.txt0000664000175000017500000000000212435110546021242 0ustar theseertheseer2 DirectoryScanner-1.3.1/tests/_data/nested/2.xml0000664000175000017500000000003712435110546021234 0ustar theseertheseer DirectoryScanner-1.3.1/tests/_data/phpfilter/javascript.js0000664000175000017500000000002712435110546023567 0ustar theseertheseer // this is javascriptDirectoryScanner-1.3.1/tests/_data/phpfilter/mixed.html0000664000175000017500000000042612435110546023062 0ustar theseertheseer Insert title here DirectoryScanner-1.3.1/tests/_data/phpfilter/phponly.php0000664000175000017500000000003712435110546023266 0ustar theseertheseer DirectoryScanner-1.3.1/tests/_data/3.xml0000664000175000017500000000003712435110546017753 0ustar theseertheseer DirectoryScanner-1.3.1/tests/directoryscanner.test.php0000664000175000017500000001566612435110546023102 0ustar theseertheseer * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package DirectoryScanner * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\DirectoryScanner\Tests { use TheSeer\DirectoryScanner\DirectoryScanner; /** * Unit tests for DirectoryScanner class * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class DirectoryScannerTest extends \PHPUnit_Framework_TestCase { /** * Test if enabling following symbolic links works. */ public function testSetFollowSymlinks() { $tmp = new DirectoryScanner(); $this->assertFalse($tmp->isFollowSymlinks()); $tmp->setFollowSymlinks(TRUE); $this->assertTrue($tmp->isFollowSymlinks()); $tmp->setFollowSymlinks(FALSE); $this->assertFalse($tmp->isFollowSymlinks()); } /** * @expectedException \TheSeer\DirectoryScanner\Exception * @expectedExceptionCode \TheSeer\DirectoryScanner\Exception::InvalidFlag */ public function testSettingInvalidFlagThrowsException() { $tmp = new DirectoryScanner(); $tmp->setFlag(-1); } /** * @expectedException \TheSeer\DirectoryScanner\Exception * @expectedExceptionCode \TheSeer\DirectoryScanner\Exception::InvalidFlag */ public function testUnSettingInvalidFlagThrowsException() { $tmp = new DirectoryScanner(); $tmp->unsetFlag(-1); } /** * Set the include to be matching for *.txt via setIncludes * */ public function testSetIncludes() { $test = array('*.txt'); $tmp = new DirectoryScanner(); $tmp->setIncludes($test); $this->assertEquals($test, $tmp->getIncludes()); } /** * Set an exclude match on *.txt * */ public function testSetExcludes() { $test = array('*.txt'); $tmp = new DirectoryScanner(); $tmp->setExcludes($test); $this->assertEquals($test, $tmp->getExcludes()); } /** * Adding multiple matches include matches individually * */ public function testAddInclude() { $tmp = new DirectoryScanner(); $tmp->addInclude('*.txt'); $tmp->addInclude('*.xml'); $this->assertEquals(2, count($tmp->getIncludes())); $this->assertEquals(array('*.txt', '*.xml'), $tmp->getIncludes()); } /** * Adding multiple exclude maches individually * */ public function testAddExclude() { $tmp = new DirectoryScanner(); $tmp->addExclude('*.txt'); $tmp->addExclude('*.xml'); $this->assertEquals(array('*.txt', '*.xml'), $tmp->getExcludes()); } /** * Trying to scan a non existend directory should throw an exception * * @expectedException \TheSeer\DirectoryScanner\Exception */ public function testScanOfNonExistendPath() { $tmp = new DirectoryScanner(); $tmp(__DIR__ . '/_data//not/existing'); } /** * Recursivly find all files within given test folder without any filter */ public function testRecursiveFindAllFilesInFolder() { $tmp = new DirectoryScanner(); $x = $tmp->getFiles(__DIR__ . '/_data'); $this->assertEquals(9, count($x)); } /** * Non-Recursivly find all files within given test folder without any filter */ public function testNonRecursiveFindAllFilesInFolder() { $tmp = new DirectoryScanner(); $x = $tmp->getFiles(__DIR__ . '/_data', FALSE); $this->assertEquals(3, count($x)); } /** * Recursivly find *.xml files within test folder */ public function testRecursiveFindXMLFilesInFolder() { $tmp = new DirectoryScanner(); $tmp->addInclude('*.xml'); $x = $tmp->getFiles(__DIR__ . '/_data'); $this->assertEquals(3, count($x)); } /** * Non-Recursivly find *.xml files within test folder */ public function testNonRecursiveFindXMLFilesInFolder() { $tmp = new DirectoryScanner(); $tmp->addInclude('*.xml'); $x = $tmp->getFiles(__DIR__ . '/_data', FALSE); $this->assertEquals(2, count($x)); } /** * Recursivly find all files, not matching *.xml */ public function testRecursiveFindByExclude() { $tmp = new DirectoryScanner(); $tmp->addExclude('*.xml'); $x = $tmp->getFiles(__DIR__ . '/_data'); $this->assertEquals(6, count($x)); } /** * Find all files matching *.txt and not being in 'nested' folder */ public function testRecursiveFindByIncludeAndExclude() { $tmp = new DirectoryScanner(); $tmp->addInclude('*.txt'); $tmp->addExclude('*/nested/*'); $x = $tmp->getFiles(__DIR__ . '/_data'); $this->assertEquals(1, count($x)); } } } DirectoryScanner-1.3.1/tests/phpfilter.test.php0000664000175000017500000000647112435110546021513 0ustar theseertheseer * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * * Neither the name of Arne Blankerts nor the names of contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @package Autoload * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. * @license BSD License */ namespace TheSeer\DirectoryScanner\Tests { /** * Unit tests for PHPFilter iterator class * * @author Arne Blankerts * @copyright Arne Blankerts , All rights reserved. */ class PHPFilterIteratorTest extends \PHPUnit_Framework_TestCase { public function testNonPHPFile() { $list = new \ArrayIterator( array( new \SplFileObject(__DIR__.'/_data/phpfilter/javascript.js') ) ); $worker = new \TheSeer\DirectoryScanner\PHPFilterIterator($list); $this->assertFalse($worker->valid()); } public function testMixedHTMLFile() { $list = new \ArrayIterator( array( new \SplFileObject(__DIR__.'/_data/phpfilter/mixed.html') ) ); $worker = new \TheSeer\DirectoryScanner\PHPFilterIterator($list); $this->assertFalse($worker->valid()); } public function testPHPFiles() { $list = new \ArrayIterator( array( new \SplFileObject(__DIR__.'/_data/phpfilter/phponly.php'), new \SplFileObject(__DIR__.'/_data/phpfilter/stupid.inc') ) ); $worker = new \TheSeer\DirectoryScanner\PHPFilterIterator($list); $worker->rewind(); $this->assertEquals(__DIR__.'/_data/phpfilter/phponly.php', $worker->current()->getPathName()); $worker->next(); $this->assertEquals(__DIR__.'/_data/phpfilter/stupid.inc', $worker->current()->getPathName()); } } }DirectoryScanner-1.3.1/LICENSE0000664000175000017500000000276612435110546015675 0ustar theseertheseerDirectoryScanner Copyright (c) 2009-2014 Arne Blankerts All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Arne Blankerts nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER ORCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. DirectoryScanner-1.3.1/phpunit.xml.dist0000664000175000017500000000152012435110546020026 0ustar theseertheseer tests src