%PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY
Server IP : 49.231.201.246 / Your IP : 216.73.216.149 Web Server : Apache/2.4.18 (Ubuntu) System : Linux 246 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : root ( 0) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : exec,passthru,shell_exec,system,proc_open,popen,pcntl_exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/water/vendor/symfony/finder/Tests/Iterator/ |
Upload File : |
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Finder\Tests\Iterator; use Symfony\Component\Finder\Iterator\SortableIterator; class SortableIteratorTest extends RealIteratorTestCase { public function testConstructor() { try { new SortableIterator(new Iterator([]), 'foobar'); $this->fail('__construct() throws an \InvalidArgumentException exception if the mode is not valid'); } catch (\Exception $e) { $this->assertInstanceOf('InvalidArgumentException', $e, '__construct() throws an \InvalidArgumentException exception if the mode is not valid'); } } /** * @dataProvider getAcceptData */ public function testAccept($mode, $expected) { if (!\is_callable($mode)) { switch ($mode) { case SortableIterator::SORT_BY_ACCESSED_TIME: touch(self::toAbsolute('.git')); sleep(1); file_get_contents(self::toAbsolute('.bar')); break; case SortableIterator::SORT_BY_CHANGED_TIME: file_put_contents(self::toAbsolute('test.php'), 'foo'); sleep(1); file_put_contents(self::toAbsolute('test.py'), 'foo'); break; case SortableIterator::SORT_BY_MODIFIED_TIME: file_put_contents(self::toAbsolute('test.php'), 'foo'); sleep(1); file_put_contents(self::toAbsolute('test.py'), 'foo'); break; } } $inner = new Iterator(self::$files); $iterator = new SortableIterator($inner, $mode); if (SortableIterator::SORT_BY_ACCESSED_TIME === $mode || SortableIterator::SORT_BY_CHANGED_TIME === $mode || SortableIterator::SORT_BY_MODIFIED_TIME === $mode ) { if ('\\' === \DIRECTORY_SEPARATOR && SortableIterator::SORT_BY_MODIFIED_TIME !== $mode) { $this->markTestSkipped('Sorting by atime or ctime is not supported on Windows'); } $this->assertOrderedIteratorForGroups($expected, $iterator); } else { $this->assertOrderedIterator($expected, $iterator); } } public function getAcceptData() { $sortByName = [ '.bar', '.foo', '.foo/.bar', '.foo/bar', '.git', 'foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', ]; $sortByType = [ '.foo', '.git', 'foo', 'toto', 'toto/.git', '.bar', '.foo/.bar', '.foo/bar', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', ]; $customComparison = [ '.bar', '.foo', '.foo/.bar', '.foo/bar', '.git', 'foo', 'foo bar', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', 'toto/.git', ]; $sortByAccessedTime = [ // For these two files the access time was set to 2005-10-15 ['foo/bar.tmp', 'test.php'], // These files were created more or less at the same time [ '.git', '.foo', '.foo/.bar', '.foo/bar', 'test.py', 'foo', 'toto', 'toto/.git', 'foo bar', ], // This file was accessed after sleeping for 1 sec ['.bar'], ]; $sortByChangedTime = [ [ '.git', '.foo', '.foo/.bar', '.foo/bar', '.bar', 'foo', 'foo/bar.tmp', 'toto', 'toto/.git', 'foo bar', ], ['test.php'], ['test.py'], ]; $sortByModifiedTime = [ [ '.git', '.foo', '.foo/.bar', '.foo/bar', '.bar', 'foo', 'foo/bar.tmp', 'toto', 'toto/.git', 'foo bar', ], ['test.php'], ['test.py'], ]; return [ [SortableIterator::SORT_BY_NAME, $this->toAbsolute($sortByName)], [SortableIterator::SORT_BY_TYPE, $this->toAbsolute($sortByType)], [SortableIterator::SORT_BY_ACCESSED_TIME, $this->toAbsolute($sortByAccessedTime)], [SortableIterator::SORT_BY_CHANGED_TIME, $this->toAbsolute($sortByChangedTime)], [SortableIterator::SORT_BY_MODIFIED_TIME, $this->toAbsolute($sortByModifiedTime)], [function (\SplFileInfo $a, \SplFileInfo $b) { return strcmp($a->getRealPath(), $b->getRealPath()); }, $this->toAbsolute($customComparison)], ]; } }