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 12namespace Symfony\Component\Finder\Tests\Iterator; 13 14use Symfony\Component\Finder\Comparator\DateComparator; 15use Symfony\Component\Finder\Iterator\DateRangeFilterIterator; 16 17class DateRangeFilterIteratorTest extends RealIteratorTestCase 18{ 19 /** 20 * @dataProvider getAcceptData 21 */ 22 public function testAccept($size, $expected) 23 { 24 $files = self::$files; 25 $files[] = self::toAbsolute('doesnotexist'); 26 $inner = new Iterator($files); 27 28 $iterator = new DateRangeFilterIterator($inner, $size); 29 30 $this->assertIterator($expected, $iterator); 31 } 32 33 public function getAcceptData() 34 { 35 $since20YearsAgo = [ 36 '.git', 37 'test.py', 38 'foo', 39 'foo/bar.tmp', 40 'test.php', 41 'toto', 42 'toto/.git', 43 '.bar', 44 '.foo', 45 '.foo/.bar', 46 'foo bar', 47 '.foo/bar', 48 ]; 49 50 $since2MonthsAgo = [ 51 '.git', 52 'test.py', 53 'foo', 54 'toto', 55 'toto/.git', 56 '.bar', 57 '.foo', 58 '.foo/.bar', 59 'foo bar', 60 '.foo/bar', 61 ]; 62 63 $untilLastMonth = [ 64 'foo/bar.tmp', 65 'test.php', 66 ]; 67 68 return [ 69 [[new DateComparator('since 20 years ago')], $this->toAbsolute($since20YearsAgo)], 70 [[new DateComparator('since 2 months ago')], $this->toAbsolute($since2MonthsAgo)], 71 [[new DateComparator('until last month')], $this->toAbsolute($untilLastMonth)], 72 ]; 73 } 74} 75