composer update

This commit is contained in:
Manish Verma
2018-12-05 10:50:52 +05:30
parent 9eabcacfa7
commit 4addd1e9c6
3328 changed files with 156676 additions and 138988 deletions

View File

@@ -24,33 +24,70 @@ class FinderTest extends Iterator\RealIteratorTestCase
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->directories());
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array('foo', 'qux', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$finder = $this->buildFinder();
$finder->directories();
$finder->files();
$finder->directories();
$this->assertIterator($this->toAbsolute(array('foo', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array('foo', 'qux', 'toto')), $finder->in(self::$tmpDir)->getIterator());
}
public function testFiles()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->files());
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp',
'test.php',
'test.py',
'foo bar',
'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());
$finder = $this->buildFinder();
$finder->files();
$finder->directories();
$finder->files();
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp',
'test.php',
'test.py',
'foo bar',
'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());
}
public function testRemoveTrailingSlash()
{
$finder = $this->buildFinder();
$expected = $this->toAbsolute(array('foo/bar.tmp', 'test.php', 'test.py', 'foo bar'));
$expected = $this->toAbsolute(array(
'foo/bar.tmp',
'test.php',
'test.py',
'foo bar',
'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',
));
$in = self::$tmpDir.'//';
$this->assertIterator($expected, $finder->in($in)->files()->getIterator());
@@ -89,26 +126,73 @@ class FinderTest extends Iterator\RealIteratorTestCase
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->depth('< 1'));
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array('foo',
'test.php',
'test.py',
'toto',
'foo bar',
'qux',
'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());
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->depth('<= 0'));
$this->assertIterator($this->toAbsolute(array('foo', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array('foo',
'test.php',
'test.py',
'toto',
'foo bar',
'qux',
'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());
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->depth('>= 1'));
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo/bar.tmp',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
)), $finder->in(self::$tmpDir)->getIterator());
$finder = $this->buildFinder();
$finder->depth('< 1')->depth('>= 1');
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
}
public function testDepthWithArrayParam()
{
$finder = $this->buildFinder();
$finder->depth(array('>= 1', '< 2'));
$this->assertIterator($this->toAbsolute(array(
'foo/bar.tmp',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
)), $finder->in(self::$tmpDir)->getIterator());
}
public function testName()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->name('*.php'));
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'test.php',
'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());
$finder = $this->buildFinder();
$finder->name('test.ph*');
@@ -121,23 +205,53 @@ class FinderTest extends Iterator\RealIteratorTestCase
$finder = $this->buildFinder();
$finder->name('~\\.php$~i');
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'test.php',
'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());
$finder = $this->buildFinder();
$finder->name('test.p{hp,y}');
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
}
public function testNameWithArrayParam()
{
$finder = $this->buildFinder();
$finder->name(array('test.php', 'test.py'));
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
}
public function testNotName()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->notName('*.php'));
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo/bar.tmp',
'test.py',
'toto',
'foo bar',
'qux',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
)), $finder->in(self::$tmpDir)->getIterator());
$finder = $this->buildFinder();
$finder->notName('*.php');
$finder->notName('*.py');
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo/bar.tmp',
'toto',
'foo bar',
'qux',
)), $finder->in(self::$tmpDir)->getIterator());
$finder = $this->buildFinder();
$finder->name('test.ph*');
@@ -153,6 +267,19 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertIterator(array(), $finder->in(self::$tmpDir)->getIterator());
}
public function testNotNameWithArrayParam()
{
$finder = $this->buildFinder();
$finder->notName(array('*.php', '*.py'));
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo/bar.tmp',
'toto',
'foo bar',
'qux',
)), $finder->in(self::$tmpDir)->getIterator());
}
/**
* @dataProvider getRegexNameTestData
*/
@@ -160,7 +287,10 @@ class FinderTest extends Iterator\RealIteratorTestCase
{
$finder = $this->buildFinder();
$finder->name($regex);
$this->assertIterator($this->toAbsolute(array('test.py', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'test.py',
'test.php',
)), $finder->in(self::$tmpDir)->getIterator());
}
public function testSize()
@@ -170,6 +300,13 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
}
public function testSizeWithArrayParam()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->files()->size(array('< 1K', '> 500')));
$this->assertIterator($this->toAbsolute(array('test.php')), $finder->in(self::$tmpDir)->getIterator());
}
public function testDate()
{
$finder = $this->buildFinder();
@@ -177,83 +314,391 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
}
public function testDateWithArrayParam()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->files()->date(array('>= 2005-10-15', 'until last month')));
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php')), $finder->in(self::$tmpDir)->getIterator());
}
public function testExclude()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->exclude('foo'));
$this->assertIterator($this->toAbsolute(array('test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'test.php',
'test.py',
'toto',
'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());
}
public function testIgnoreVCS()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'.git',
'foo',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'toto/.git',
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'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());
$finder = $this->buildFinder();
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'.git',
'foo',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'toto/.git',
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'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());
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'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());
}
public function testIgnoreDotFiles()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->ignoreDotFiles(false)->ignoreVCS(false));
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'.git',
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'foo',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'toto/.git',
'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());
$finder = $this->buildFinder();
$finder->ignoreDotFiles(false)->ignoreDotFiles(false)->ignoreVCS(false);
$this->assertIterator($this->toAbsolute(array('.git', '.bar', '.foo', '.foo/.bar', '.foo/bar', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'.git',
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'foo',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'toto/.git',
'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());
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->ignoreDotFiles(true)->ignoreVCS(false));
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'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());
}
public function testSortByName()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByName());
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo bar',
'foo/bar.tmp',
'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',
'test.php',
'test.py',
'toto',
)), $finder->in(self::$tmpDir)->getIterator());
}
public function testSortByType()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByType());
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'toto', 'foo/bar.tmp', 'test.php', 'test.py')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo bar',
'toto',
'foo/bar.tmp',
'test.php',
'test.py',
'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());
}
public function testSortByAccessedTime()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByAccessedTime());
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo/bar.tmp',
'test.php',
'toto',
'test.py',
'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());
}
public function testSortByChangedTime()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByChangedTime());
$this->assertIterator($this->toAbsolute(array('toto', 'test.py', 'test.php', 'foo/bar.tmp', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'toto',
'test.py',
'test.php',
'foo/bar.tmp',
'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());
}
public function testSortByModifiedTime()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByModifiedTime());
$this->assertIterator($this->toAbsolute(array('foo/bar.tmp', 'test.php', 'toto', 'test.py', 'foo', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo/bar.tmp',
'test.php',
'toto',
'test.py',
'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());
}
public function testReverseSorting()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByName());
$this->assertSame($finder, $finder->reverseSorting());
$this->assertOrderedIteratorInForeach($this->toAbsolute(array(
'toto',
'test.py',
'test.php',
'qux_2_0.php',
'qux_12_0.php',
'qux_10_2.php',
'qux_1002_0.php',
'qux_1000_1.php',
'qux_0_1.php',
'qux/baz_1_2.py',
'qux/baz_100_1.py',
'qux',
'foo/bar.tmp',
'foo bar',
'foo',
)), $finder->in(self::$tmpDir)->getIterator());
}
public function testSortByNameNatural()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByName(true));
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo bar',
'foo/bar.tmp',
'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',
'test.php',
'test.py',
'toto',
)), $finder->in(self::$tmpDir)->getIterator());
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sortByName(false));
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo bar',
'foo/bar.tmp',
'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',
'test.php',
'test.py',
'toto',
)), $finder->in(self::$tmpDir)->getIterator());
}
public function testSort()
{
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->sort(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }));
$this->assertIterator($this->toAbsolute(array('foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo bar',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'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());
}
public function testFilter()
@@ -271,7 +716,23 @@ class FinderTest extends Iterator\RealIteratorTestCase
$finder = $this->buildFinder();
$this->assertSame($finder, $finder->followLinks());
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'foo bar')), $finder->in(self::$tmpDir)->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'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());
}
public function testIn()
@@ -283,6 +744,12 @@ class FinderTest extends Iterator\RealIteratorTestCase
self::$tmpDir.\DIRECTORY_SEPARATOR.'test.php',
__DIR__.\DIRECTORY_SEPARATOR.'FinderTest.php',
__DIR__.\DIRECTORY_SEPARATOR.'GlobTest.php',
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_0_1.php',
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1000_1.php',
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_1002_0.php',
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_10_2.php',
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_12_0.php',
self::$tmpDir.\DIRECTORY_SEPARATOR.'qux_2_0.php',
);
$this->assertIterator($expected, $iterator);
@@ -339,7 +806,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$dirs[] = (string) $dir;
}
$expected = $this->toAbsolute(array('foo', 'toto'));
$expected = $this->toAbsolute(array('foo', 'qux', 'toto'));
sort($dirs);
sort($expected);
@@ -347,7 +814,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$this->assertEquals($expected, $dirs, 'implements the \IteratorAggregate interface');
$finder = $this->buildFinder();
$this->assertEquals(2, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
$this->assertEquals(3, iterator_count($finder->directories()->in(self::$tmpDir)), 'implements the \IteratorAggregate interface');
$finder = $this->buildFinder();
$a = iterator_to_array($finder->directories()->in(self::$tmpDir));
@@ -366,7 +833,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$paths[] = $file->getRelativePath();
}
$ref = array('', '', '', '', 'foo', '');
$ref = array('', '', '', '', '', '', '', '', '', '', '', 'foo', 'qux', 'qux', '');
sort($ref);
sort($paths);
@@ -384,7 +851,23 @@ class FinderTest extends Iterator\RealIteratorTestCase
$paths[] = $file->getRelativePathname();
}
$ref = array('test.php', 'toto', 'test.py', 'foo', 'foo'.\DIRECTORY_SEPARATOR.'bar.tmp', 'foo bar');
$ref = array(
'test.php',
'toto',
'test.py',
'foo',
'foo'.\DIRECTORY_SEPARATOR.'bar.tmp',
'foo bar',
'qux',
'qux'.\DIRECTORY_SEPARATOR.'baz_100_1.py',
'qux'.\DIRECTORY_SEPARATOR.'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',
);
sort($paths);
sort($ref);
@@ -402,7 +885,7 @@ class FinderTest extends Iterator\RealIteratorTestCase
$finder = $finder->append($finder1);
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'toto')), $finder->getIterator());
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'qux', 'toto')), $finder->getIterator());
}
public function testAppendWithAnArray()
@@ -595,13 +1078,15 @@ class FinderTest extends Iterator\RealIteratorTestCase
array('lorem', 'foobar', array('lorem.txt')),
array('', 'lorem', array('dolor.txt', 'ipsum.txt')),
array('ipsum dolor sit amet', '/^IPSUM/m', array('lorem.txt')),
array(array('lorem', 'dolor'), array(), array('lorem.txt', 'ipsum.txt', 'dolor.txt')),
array('', array('lorem', 'ipsum'), array('dolor.txt')),
);
}
public function getRegexNameTestData()
{
return array(
array('~.+\\.p.+~i'),
array('~.*t\\.p.+~i'),
array('~t.*s~i'),
);
}
@@ -661,6 +1146,33 @@ class FinderTest extends Iterator\RealIteratorTestCase
'with space'.\DIRECTORY_SEPARATOR.'foo.txt',
),
),
array(
'/^A/',
array('a.dat', 'abc.dat'),
array(
'A',
'A'.\DIRECTORY_SEPARATOR.'B',
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C',
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
),
),
array(
array('/^A/', 'one'),
'foobar',
array(
'A',
'A'.\DIRECTORY_SEPARATOR.'B',
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C',
'A'.\DIRECTORY_SEPARATOR.'a.dat',
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'ab.dat',
'A'.\DIRECTORY_SEPARATOR.'B'.\DIRECTORY_SEPARATOR.'C'.\DIRECTORY_SEPARATOR.'abc.dat',
'one',
'one'.\DIRECTORY_SEPARATOR.'a',
'one'.\DIRECTORY_SEPARATOR.'b',
'one'.\DIRECTORY_SEPARATOR.'b'.\DIRECTORY_SEPARATOR.'c.neon',
'one'.\DIRECTORY_SEPARATOR.'b'.\DIRECTORY_SEPARATOR.'d.neon',
),
),
);
}
@@ -718,7 +1230,20 @@ class FinderTest extends Iterator\RealIteratorTestCase
chmod($testDir, 0333);
if (false === ($couldRead = is_readable($testDir))) {
$this->assertIterator($this->toAbsolute(array('foo bar', 'test.php', 'test.py')), $finder->getIterator());
$this->assertIterator($this->toAbsolute(array(
'foo bar',
'test.php',
'test.py',
'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->getIterator());
}
// restore original permissions
@@ -730,8 +1255,26 @@ class FinderTest extends Iterator\RealIteratorTestCase
}
}
/**
* @group legacy
* @expectedDeprecation The "Symfony\Component\Finder\Finder::sortByName()" method will have a new "bool $useNaturalSort = false" argument in version 5.0, not defining it is deprecated since Symfony 4.2.
*/
public function testInheritedClassCallSortByNameWithNoArguments()
{
$finderChild = new ClassThatInheritFinder();
$finderChild->sortByName();
}
protected function buildFinder()
{
return Finder::create();
}
}
class ClassThatInheritFinder extends Finder
{
public function sortByName()
{
parent::sortByName();
}
}

View File

@@ -45,6 +45,15 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
'.foo/.bar',
'foo bar',
'.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',
);
$since2MonthsAgo = array(
@@ -58,6 +67,15 @@ class DateRangeFilterIteratorTest extends RealIteratorTestCase
'.foo/.bar',
'foo bar',
'.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',
);
$untilLastMonth = array(

View File

@@ -41,6 +41,13 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
'.foo',
'.bar',
'foo bar',
'qux',
'qux_0_1.php',
'qux_1000_1.php',
'qux_1002_0.php',
'qux_10_2.php',
'qux_12_0.php',
'qux_2_0.php',
);
$lessThanOrEqualTo1 = array(
@@ -56,6 +63,15 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
'.bar',
'foo bar',
'.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',
);
$graterThanOrEqualTo1 = array(
@@ -63,6 +79,8 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
'foo/bar.tmp',
'.foo/.bar',
'.foo/bar',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
);
$equalTo1 = array(
@@ -70,6 +88,8 @@ class DepthRangeFilterIteratorTest extends RealIteratorTestCase
'foo/bar.tmp',
'.foo/.bar',
'.foo/bar',
'qux/baz_100_1.py',
'qux/baz_1_2.py',
);
return array(

View File

@@ -41,6 +41,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
'toto',
'toto/.git',
'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',
);
$fo = array(
@@ -56,6 +65,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
'toto',
'toto/.git',
'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',
);
$toto = array(
@@ -69,6 +87,15 @@ class ExcludeDirectoryFilterIteratorTest extends RealIteratorTestCase
'foo/bar.tmp',
'test.php',
'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',
);
return array(

View File

@@ -37,11 +37,20 @@ class FileTypeFilterIteratorTest extends RealIteratorTestCase
'.foo/.bar',
'.foo/bar',
'foo bar',
'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',
);
$onlyDirectories = array(
'.git',
'foo',
'qux',
'toto',
'toto/.git',
'.foo',

View File

@@ -29,12 +29,12 @@ class MockSplFileInfo extends \SplFileInfo
parent::__construct($param);
} elseif (\is_array($param)) {
$defaults = array(
'name' => 'file.txt',
'contents' => null,
'mode' => null,
'type' => null,
'relativePath' => null,
'relativePathname' => null,
'name' => 'file.txt',
'contents' => null,
'mode' => null,
'type' => null,
'relativePath' => null,
'relativePathname' => null,
);
$defaults = array_merge($defaults, $param);
parent::__construct($defaults['name']);

View File

@@ -33,6 +33,15 @@ abstract class RealIteratorTestCase extends IteratorTestCase
'toto/',
'toto/.git/',
'foo bar',
'qux_0_1.php',
'qux_2_0.php',
'qux_10_2.php',
'qux_12_0.php',
'qux_1000_1.php',
'qux_1002_0.php',
'qux/',
'qux/baz_1_2.py',
'qux/baz_100_1.py',
);
self::$files = self::toAbsolute(self::$files);

View File

@@ -34,6 +34,7 @@ class SizeRangeFilterIteratorTest extends RealIteratorTestCase
'.foo',
'.git',
'foo',
'qux',
'test.php',
'toto',
'toto/.git',

View File

@@ -82,6 +82,15 @@ class SortableIteratorTest extends RealIteratorTestCase
'foo',
'foo bar',
'foo/bar.tmp',
'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',
'test.php',
'test.py',
'toto',
@@ -92,6 +101,7 @@ class SortableIteratorTest extends RealIteratorTestCase
'.foo',
'.git',
'foo',
'qux',
'toto',
'toto/.git',
'.bar',
@@ -99,25 +109,18 @@ class SortableIteratorTest extends RealIteratorTestCase
'.foo/bar',
'foo bar',
'foo/bar.tmp',
'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',
'test.php',
'test.py',
);
$customComparison = array(
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'.git',
'foo',
'foo bar',
'foo/bar.tmp',
'test.php',
'test.py',
'toto',
'toto/.git',
);
$sortByAccessedTime = array(
// For these two files the access time was set to 2005-10-15
array('foo/bar.tmp', 'test.php'),
@@ -132,6 +135,15 @@ class SortableIteratorTest extends RealIteratorTestCase
'toto',
'toto/.git',
'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',
),
// This file was accessed after sleeping for 1 sec
array('.bar'),
@@ -149,6 +161,15 @@ class SortableIteratorTest extends RealIteratorTestCase
'toto',
'toto/.git',
'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',
),
array('test.php'),
array('test.py'),
@@ -166,17 +187,75 @@ class SortableIteratorTest extends RealIteratorTestCase
'toto',
'toto/.git',
'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',
),
array('test.php'),
array('test.py'),
);
$sortByNameNatural = array(
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'.git',
'foo',
'foo/bar.tmp',
'foo bar',
'qux',
'qux/baz_1_2.py',
'qux/baz_100_1.py',
'qux_0_1.php',
'qux_2_0.php',
'qux_10_2.php',
'qux_12_0.php',
'qux_1000_1.php',
'qux_1002_0.php',
'test.php',
'test.py',
'toto',
'toto/.git',
);
$customComparison = array(
'.bar',
'.foo',
'.foo/.bar',
'.foo/bar',
'.git',
'foo',
'foo bar',
'foo/bar.tmp',
'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',
'test.php',
'test.py',
'toto',
'toto/.git',
);
return array(
array(SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)),
array(SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)),
array(SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)),
array(SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)),
array(SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)),
array(SortableIterator::SORT_BY_NAME_NATURAL, $this->toAbsolute($sortByNameNatural)),
array(function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)),
);
}