Yaffs site version 1.1
[yaffs-website] / vendor / symfony / finder / Tests / Iterator / FilePathsIteratorTest.php
1 <?php
2
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 namespace Symfony\Component\Finder\Tests\Iterator;
13
14 use Symfony\Component\Finder\Iterator\FilePathsIterator;
15
16 /**
17  * @group legacy
18  */
19 class FilePathsIteratorTest extends RealIteratorTestCase
20 {
21     /**
22      * @dataProvider getSubPathData
23      */
24     public function testSubPath($baseDir, array $paths, array $subPaths, array $subPathnames)
25     {
26         $iterator = new FilePathsIterator($paths, $baseDir);
27
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());
32         }
33     }
34
35     public function getSubPathData()
36     {
37         $tmpDir = sys_get_temp_dir().'/symfony_finder';
38
39         return array(
40             array(
41                 $tmpDir,
42                 array(
43                     // paths
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',
50                 ),
51                 array(
52                     // subPaths
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' => '',
59                 ),
60                 array(
61                     // subPathnames
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',
68                 ),
69             ),
70         );
71     }
72 }