4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Finder\Tests\Iterator;
14 use Symfony\Component\Finder\Iterator\FilePathsIterator;
19 class FilePathsIteratorTest extends RealIteratorTestCase
22 * @dataProvider getSubPathData
24 public function testSubPath($baseDir, array $paths, array $subPaths, array $subPathnames)
26 $iterator = new FilePathsIterator($paths, $baseDir);
28 foreach ($iterator as $index => $file) {
29 $this->assertEquals($paths[$index], $file->getPathname());
30 $this->assertEquals($subPaths[$index], $iterator->getSubPath());
31 $this->assertEquals($subPathnames[$index], $iterator->getSubPathname());
35 public function getSubPathData()
37 $tmpDir = sys_get_temp_dir().'/symfony_finder';
44 $tmpDir.DIRECTORY_SEPARATOR.'.git' => $tmpDir.DIRECTORY_SEPARATOR.'.git',
45 $tmpDir.DIRECTORY_SEPARATOR.'test.py' => $tmpDir.DIRECTORY_SEPARATOR.'test.py',
46 $tmpDir.DIRECTORY_SEPARATOR.'foo' => $tmpDir.DIRECTORY_SEPARATOR.'foo',
47 $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
48 $tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php',
49 $tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto',
53 $tmpDir.DIRECTORY_SEPARATOR.'.git' => '',
54 $tmpDir.DIRECTORY_SEPARATOR.'test.py' => '',
55 $tmpDir.DIRECTORY_SEPARATOR.'foo' => '',
56 $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo',
57 $tmpDir.DIRECTORY_SEPARATOR.'test.php' => '',
58 $tmpDir.DIRECTORY_SEPARATOR.'toto' => '',
62 $tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git',
63 $tmpDir.DIRECTORY_SEPARATOR.'test.py' => 'test.py',
64 $tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo',
65 $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
66 $tmpDir.DIRECTORY_SEPARATOR.'test.php' => 'test.php',
67 $tmpDir.DIRECTORY_SEPARATOR.'toto' => 'toto',