Skip to content

Commit

Permalink
additional test adjustments
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Richards <josh.t.richards@gmail.com>
  • Loading branch information
joshtrichards committed May 8, 2024
1 parent 6912c9a commit 5b49aa6
Showing 1 changed file with 53 additions and 7 deletions.
60 changes: 53 additions & 7 deletions src/Symfony/Component/Finder/Tests/FinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public function testDirectories()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->directories());
$this->assertIterator($this->toAbsolute(['foo', 'qux', 'toto']), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(['foo', 'qux', 'toto', 'toto/foo']), $finder->in(self::$tmpDir)->getIterator());

$finder = $this->buildFinder();
$finder->directories();
$finder->files();
$finder->directories();
$this->assertIterator($this->toAbsolute(['foo', 'qux', 'toto']), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(['foo', 'qux', 'toto', 'toto/foo']), $finder->in(self::$tmpDir)->getIterator());
}

public function testFiles()
Expand Down Expand Up @@ -162,7 +162,8 @@ public function testDepth()
$this->assertIterator($this->toAbsolute([
'foo/bar.tmp',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
'qux/baz_1_2.py',
'toto/foo',
]), $finder->in(self::$tmpDir)->getIterator());

$finder = $this->buildFinder();
Expand All @@ -178,6 +179,7 @@ public function testDepthWithArrayParam()
'foo/bar.tmp',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
'toto/foo',
]), $finder->in(self::$tmpDir)->getIterator());
}

Expand Down Expand Up @@ -237,6 +239,7 @@ public function testNotName()
'foo/bar.tmp',
'test.py',
'toto',
'toto/foo',
'foo bar',
'qux',
'qux/baz_100_1.py',
Expand All @@ -250,6 +253,7 @@ public function testNotName()
'foo',
'foo/bar.tmp',
'toto',
'toto/foo',
'foo bar',
'qux',
]), $finder->in(self::$tmpDir)->getIterator());
Expand All @@ -276,6 +280,7 @@ public function testNotNameWithArrayParam()
'foo',
'foo/bar.tmp',
'toto',
'toto/foo',
'foo bar',
'qux',
]), $finder->in(self::$tmpDir)->getIterator());
Expand Down Expand Up @@ -340,6 +345,25 @@ public function testExclude()
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
]), $finder->in(self::$tmpDir)->getIterator());

$finder = $this->buildFinder();
$this->assertSame($finder, $finder->exclude('/foo'));
$this->assertIterator($this->toAbsolute([
'test.php',
'test.py',
'toto',
'toto/foo',
'foo bar',
'qux',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
'qux_0_1.php',
'qux_1000_1.php',
'qux_1002_0.php',
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
]), $finder->in(self::$tmpDir)->getIterator());
}

Expand All @@ -355,6 +379,7 @@ public function testIgnoreVCS()
'test.py',
'toto',
'toto/.git',
'toto/foo',
'.bar',
'.foo',
'.foo/.bar',
Expand All @@ -380,6 +405,7 @@ public function testIgnoreVCS()
'test.php',
'test.py',
'toto',
'toto/foo',
'toto/.git',
'.bar',
'.foo',
Expand All @@ -405,6 +431,7 @@ public function testIgnoreVCS()
'test.php',
'test.py',
'toto',
'toto/foo',
'.bar',
'.foo',
'.foo/.bar',
Expand Down Expand Up @@ -468,6 +495,7 @@ public function testIgnoreVCSCanBeDisabledAfterFirstIteration()
'test.php',
'test.py',
'toto',
'toto/foo',
'.bar',
'.foo',
'.foo/.bar',
Expand All @@ -492,6 +520,7 @@ public function testIgnoreVCSCanBeDisabledAfterFirstIteration()
'test.php',
'test.py',
'toto',
'toto/foo',
'toto/.git',
'.bar',
'.foo',
Expand All @@ -517,6 +546,7 @@ public function testIgnoreDotFiles()
'test.py',
'toto',
'toto/.git',
'toto/foo',
'foo bar',
'qux',
'qux/baz_100_1.py',
Expand All @@ -542,6 +572,7 @@ public function testIgnoreDotFiles()
'test.php',
'test.py',
'toto',
'toto/foo',
'toto/.git',
'foo bar',
'qux',
Expand All @@ -563,6 +594,7 @@ public function testIgnoreDotFiles()
'test.php',
'test.py',
'toto',
'toto/foo',
'foo bar',
'qux',
'qux/baz_100_1.py',
Expand Down Expand Up @@ -596,6 +628,7 @@ public function testIgnoreDotFilesCanBeDisabledAfterFirstIteration()
'test.php',
'test.py',
'toto',
'toto/foo',
'foo bar',
]), $finder->getIterator());

Expand All @@ -615,6 +648,7 @@ public function testIgnoreDotFilesCanBeDisabledAfterFirstIteration()
'test.php',
'test.py',
'toto',
'toto/foo',
'.bar',
'.foo',
'.foo/.bar',
Expand Down Expand Up @@ -643,6 +677,7 @@ public function testSortByName()
'test.php',
'test.py',
'toto',
'toto/foo',
]), $finder->in(self::$tmpDir)->getIterator());
}

Expand All @@ -654,6 +689,7 @@ public function testSortByType()
'foo',
'qux',
'toto',
'toto/foo',
'foo bar',
'foo/bar.tmp',
'qux/baz_100_1.py',
Expand All @@ -677,6 +713,7 @@ public function testSortByAccessedTime()
'foo/bar.tmp',
'test.php',
'toto',
'toto/foo',
'test.py',
'foo',
'foo bar',
Expand All @@ -698,6 +735,7 @@ public function testSortByChangedTime()
$this->assertSame($finder, $finder->sortByChangedTime());
$this->assertIterator($this->toAbsolute([
'toto',
'toto/foo',
'test.py',
'test.php',
'foo/bar.tmp',
Expand All @@ -723,6 +761,7 @@ public function testSortByModifiedTime()
'foo/bar.tmp',
'test.php',
'toto',
'toto/foo',
'test.py',
'foo',
'foo bar',
Expand All @@ -744,6 +783,7 @@ public function testReverseSorting()
$this->assertSame($finder, $finder->sortByName());
$this->assertSame($finder, $finder->reverseSorting());
$this->assertOrderedIteratorInForeach($this->toAbsolute([
'toto/foo',
'toto',
'test.py',
'test.php',
Expand Down Expand Up @@ -782,6 +822,7 @@ public function testSortByNameNatural()
'test.php',
'test.py',
'toto',
'toto/foo',
]), $finder->in(self::$tmpDir)->getIterator());

$finder = $this->buildFinder();
Expand All @@ -802,6 +843,7 @@ public function testSortByNameNatural()
'test.php',
'test.py',
'toto',
'toto/foo',
]), $finder->in(self::$tmpDir)->getIterator());
}

Expand All @@ -825,6 +867,7 @@ public function testSort()
'test.php',
'test.py',
'toto',
'toto/foo',
]), $finder->in(self::$tmpDir)->getIterator());
}

Expand Down Expand Up @@ -882,6 +925,7 @@ public function testFollowLinks()
'test.php',
'test.py',
'toto',
'toto/foo',
'foo bar',
'qux',
'qux/baz_100_1.py',
Expand Down Expand Up @@ -972,15 +1016,15 @@ public function testGetIterator()
$dirs[] = (string) $dir;
}

$expected = $this->toAbsolute(['foo', 'qux', 'toto']);
$expected = $this->toAbsolute(['foo', 'qux', 'toto', 'toto/foo']);

sort($dirs);
sort($expected);

$this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');

$finder = $this->buildFinder();
$this->assertEquals(3, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
$this->assertEquals(4, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');

$finder = $this->buildFinder();
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
Expand All @@ -999,7 +1043,7 @@ public function testRelativePath()
$paths[] = $file->getRelativePath();
}

$ref = ['', '', '', '', '', '', '', '', '', '', '', 'foo', 'qux', 'qux', ''];
$ref = ['', '', '', '', '', '', '', '', '', '', '', 'foo', 'qux', 'qux', '', 'toto'];

sort($ref);
sort($paths);
Expand All @@ -1020,6 +1064,7 @@ public function testRelativePathname()
$ref = [
'test.php',
'toto',
'toto/foo',
'test.py',
'foo',
'foo'.\DIRECTORY_SEPARATOR.'bar.tmp',
Expand Down Expand Up @@ -1056,6 +1101,7 @@ public function testGetFilenameWithoutExtension()
'toto',
'test',
'foo',
'foo',
'bar',
'foo bar',
'qux',
Expand Down Expand Up @@ -1085,7 +1131,7 @@ public function testAppendWithAFinder()

$finder = $finder->append($finder1);

$this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'qux', 'toto']), $finder->getIterator());
$this->assertIterator($this->toAbsolute(['foo', 'foo/bar.tmp', 'qux', 'toto', 'toto/foo']), $finder->getIterator());
}

public function testAppendWithAnArray()
Expand Down

0 comments on commit 5b49aa6

Please sign in to comment.