Exemplo n.º 1
0
 public function testTrackingFunctionally()
 {
     $file = tempnam(sys_get_temp_dir(), 'sf2_resource_watcher_');
     $event = null;
     $watcher = new ResourceWatcher();
     $watcher->trackByListener($file, function ($firedEvent) use(&$event) {
         $event = $firedEvent;
     });
     usleep(2000000);
     touch($file);
     $watcher->start(1, 1);
     $this->assertNotNull($event);
     $this->assertSame($file, (string) $event->getResource());
     $this->assertSame(FilesystemEvent::MODIFY, $event->getType());
     $watcher->stop();
     unlink($file);
     $watcher->start(1, 1);
     $this->assertNotNull($event);
     $this->assertSame($file, (string) $event->getResource());
     $this->assertSame(FilesystemEvent::DELETE, $event->getType());
 }