Example #1
0
 /**
  * Returns true if the cache is outdated.
  *
  * @return bool true, cache is outdated of non exsitant.
  */
 public function isOutdated()
 {
     $this->boot();
     $compiled_tracked_files = new TrackedFiles([$this->output_dir]);
     $current_tracked_files = new TrackedFiles($this->paths);
     if ($current_tracked_files->modifiedAfter($compiled_tracked_files)) {
         $this->profiler->set('tracker.reason', 'One of the tracked files has been modified.');
         return true;
     }
     $this->profiler->set('tracker.reason', false);
     return false;
 }
 /**
  * What happens when a file is modified after 'compilation'
  */
 public function testModifyAfter()
 {
     $time = time();
     $file = tempnam($this->directory_a, 'tracked_files_unittest_a_file1');
     touch($file, $time - 100);
     $file = tempnam($this->directory_b, 'tracked_files_unittest_b_file1');
     touch($file, $time - 50);
     $file = tempnam($this->directory_a, 'tracked_files_unittest_a_file2');
     touch($file, $time);
     $t1 = new TrackedFiles([$this->directory_a]);
     $t2 = new TrackedFiles([$this->directory_b]);
     self::assertTrue($t1->modifiedAfter($t2));
     self::assertFalse($t2->modifiedAfter($t1));
 }