TYPO3  7.6
FilePathsIteratorTest.php
Go to the documentation of this file.
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 
15 
17 {
21  public function testSubPath($baseDir, array $paths, array $subPaths, array $subPathnames)
22  {
23  $iterator = new FilePathsIterator($paths, $baseDir);
24 
25  foreach ($iterator as $index => $file) {
26  $this->assertEquals($paths[$index], $file->getPathname());
27  $this->assertEquals($subPaths[$index], $iterator->getSubPath());
28  $this->assertEquals($subPathnames[$index], $iterator->getSubPathname());
29  }
30  }
31 
32  public function getSubPathData()
33  {
34  $tmpDir = sys_get_temp_dir().'/symfony_finder';
35 
36  return array(
37  array(
38  $tmpDir,
39  array(
40  // paths
41  $tmpDir.DIRECTORY_SEPARATOR.'.git' => $tmpDir.DIRECTORY_SEPARATOR.'.git',
42  $tmpDir.DIRECTORY_SEPARATOR.'test.py' => $tmpDir.DIRECTORY_SEPARATOR.'test.py',
43  $tmpDir.DIRECTORY_SEPARATOR.'foo' => $tmpDir.DIRECTORY_SEPARATOR.'foo',
44  $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
45  $tmpDir.DIRECTORY_SEPARATOR.'test.php' => $tmpDir.DIRECTORY_SEPARATOR.'test.php',
46  $tmpDir.DIRECTORY_SEPARATOR.'toto' => $tmpDir.DIRECTORY_SEPARATOR.'toto',
47  ),
48  array(
49  // subPaths
50  $tmpDir.DIRECTORY_SEPARATOR.'.git' => '',
51  $tmpDir.DIRECTORY_SEPARATOR.'test.py' => '',
52  $tmpDir.DIRECTORY_SEPARATOR.'foo' => '',
53  $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo',
54  $tmpDir.DIRECTORY_SEPARATOR.'test.php' => '',
55  $tmpDir.DIRECTORY_SEPARATOR.'toto' => '',
56  ),
57  array(
58  // subPathnames
59  $tmpDir.DIRECTORY_SEPARATOR.'.git' => '.git',
60  $tmpDir.DIRECTORY_SEPARATOR.'test.py' => 'test.py',
61  $tmpDir.DIRECTORY_SEPARATOR.'foo' => 'foo',
62  $tmpDir.DIRECTORY_SEPARATOR.'foo'.DIRECTORY_SEPARATOR.'bar.tmp' => 'foo'.DIRECTORY_SEPARATOR.'bar.tmp',
63  $tmpDir.DIRECTORY_SEPARATOR.'test.php' => 'test.php',
64  $tmpDir.DIRECTORY_SEPARATOR.'toto' => 'toto',
65  ),
66  ),
67  );
68  }
69 }