public function testDetectingOfResourceDeleted()
 {
     $files = m::mock('Illuminate\\Filesystem\\Filesystem');
     $files->shouldReceive('exists')->once()->andReturn(true);
     $files->shouldReceive('exists')->once()->andReturn(false);
     $files->shouldReceive('lastModified')->once()->andReturn(time());
     $resource = new FileResource(new SplFileInfo(__FILE__), $files);
     $events = $resource->detectChanges();
     $this->assertInstanceOf('JasonLewis\\ResourceWatcher\\Event', $event = array_pop($events));
     $this->assertEquals(Event::RESOURCE_DELETED, $event->getCode());
 }
 /**
  * Detect the descendant resources of the directory.
  *
  * @return array
  */
 protected function detectDirectoryDescendants()
 {
     $descendants = [];
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->getPath())) as $file) {
         if ($file->isDir() && !in_array($file->getBasename(), array('.', '..'))) {
             $resource = new DirectoryResource($file, $this->files);
             $descendants[$resource->getKey()] = $resource;
         } elseif ($file->isFile()) {
             $resource = new FileResource($file, $this->files);
             $descendants[$resource->getKey()] = $resource;
         }
     }
     return $descendants;
 }