/** * Tests isOutdated() * * @dataProvider provideTestIsOutdated * @param string $mtime file time * @param string $time current time * @param bool $expectedIsOutdated * @see UpdatePlan::isOutdated() */ public function testIsOutdated($mtime, $time, $expectedIsOutdated) { $fileUtil = new FileUtil(); $file = tempnam($fileUtil->getTempDirectory(), 'bavtest'); touch($file, strtotime($mtime)); $backend = new FileDataBackend($file); TimeMock::setTime(strtotime($time)); $updatePlan = new AutomaticUpdatePlan(); $this->assertEquals($expectedIsOutdated, $updatePlan->isOutdated($backend)); TimeMock::disable(); }
/** * time() mock. * * This mock works only if the built-in wasn't used before. I.e. tests * which want to mock time() have to run before other tests which might * call somewhere in the stack an unmocked time(). If the built in was * called before there is no chance to mock time() anymore. */ function time() { return TimeMock::time(); }