/** * @dataProvider getTestData */ public function testTest($test, $match, $noMatch) { $c = new DateComparator($test); foreach ($match as $m) { $this->assertTrue($c->test($m), '->test() tests a string against the expression'); } foreach ($noMatch as $m) { $this->assertFalse($c->test($m), '->test() tests a string against the expression'); } }
/** * Adds tests for file dates (last modified). * * The date must be something that strtotime() is able to parse: * * $collection->filterByDate('since yesterday'); * $collection->filterByDate('until 2 days ago'); * $collection->filterByDate('> now - 2 hours'); * $collection->filterByDate('>= 2005-10-15'); * * @param string $date A date to test * * @return FilesCollection * * @see DateComparator */ public function date($date) { $comparator = new DateComparator($date); return $this->filter(function (SplFileInfo $file) use($comparator) { return $comparator->test($file->getMTime()); }); }