Exemplo n.º 1
0
 public function testCanGetResourceAttributes()
 {
     $files = m::mock('Illuminate\\Filesystem\\Filesystem');
     $files->shouldReceive('exists')->once()->andReturn(true);
     $files->shouldReceive('lastModified')->twice()->andReturn($modified = time());
     $resource = new FileResource(new SplFileInfo(__FILE__), $files);
     $this->assertEquals(md5(__FILE__), $resource->getKey());
     $this->assertEquals(__FILE__, $resource->getPath());
     $this->assertEquals($modified, $resource->getLastModified());
     $this->assertFalse($resource->isModified());
 }
 /**
  * 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;
 }