Пример #1
0
 public function remove(TrackedObject $tracked)
 {
     $path = (string) $tracked->getResource();
     if (in_array($path, $this->listener->getPaths())) {
         return;
     }
     unset($this->map[$tracked->getID()]);
     $this->adapter->unwatch($tracked);
 }
Пример #2
0
 function it_should_start_evaluate_filesystem_event_properly(AdapterInterface $adapter, LoggerInterface $logger, FilesystemEvent $event)
 {
     $this->callback(function (ChangeSetEvent $event) {
         static $count = 0;
         $event->getListener()->stop();
         $count++;
     });
     $adapter->setLogger($logger)->shouldBeCalled();
     $adapter->initialize($this)->shouldBeCalled();
     $adapter->evaluate()->shouldBeCalled();
     $adapter->getChangeSet()->willReturn(array($event))->shouldBeCalled();
     $this->setLogger($logger);
     $this->to(mfs::$tmpDir);
     $this->setAdapter($adapter);
     $this->latency(10000);
     $this->start();
     $this->getChangeset()->shouldContain($event);
 }
Пример #3
0
 /**
  * @param \PhpGuard\Listen\Adapter\AdapterInterface $adapter
  *
  * @return Listener
  */
 public function setAdapter($adapter)
 {
     $this->adapter = $adapter;
     $adapter->initialize($this);
     return $this;
 }
Пример #4
0
 function its_checkPath_should_track_on_filesystem_delete_event(AdapterInterface $adapter, FileResource $resource, TrackedObject $tracked)
 {
     $tracked->getResource()->shouldBeCalled()->willReturn($resource);
     $tracked->getChecksum()->shouldBeCalled()->willReturn('checksum');
     $resource->isExists()->shouldBeCalled()->willReturn(false);
     $resource->getChecksum()->willReturn('new_checksum')->shouldBeCalled();
     $resource->getResource()->willReturn($this->testFile);
     $adapter->unwatch($tracked)->shouldBeCalled();
     $this->checkPath($this->testFile);
     $this->getChangeSet()->shouldHaveCount(1);
 }