/**
  * Get thumbnails
  *
  * @param Media       $media media instance
  * @param null|string $type  thumbnail make type
  * @return Image[]
  */
 public function getThumbnails(Media $media, $type = null)
 {
     $wheres = ['originId' => $media->getFile()->getId()];
     if ($type !== null) {
         $wheres = array_merge($wheres, ['type' => $type]);
     }
     $metas = $this->repo->fetch($wheres);
     $tmp = [];
     foreach ($metas as $meta) {
         $tmp[$meta->id] = $meta;
     }
     $metas = $tmp;
     $files = $this->storage->children($media->getFile());
     $result = [];
     foreach ($files as $file) {
         if (isset($metas[$file->getId()]) === true) {
             $result[] = $this->createModel($file, $metas[$file->getId()]);
         }
     }
     return $result;
 }
 public function testChildren()
 {
     list($handler, $repo, $auth, $keygen) = $this->getMocks();
     $mockFile = m::mock('Xpressengine\\Storage\\File');
     $mockFile->id = 'fileidstring';
     $mockChild1 = m::mock('Xpressengine\\Storage\\File');
     $mockChild2 = m::mock('Xpressengine\\Storage\\File');
     $repo->shouldReceive('fetch')->once()->with(['parentId' => 'fileidstring'])->andReturn([$mockChild1, $mockChild2]);
     $instance = new Storage($handler, $repo, $auth, $keygen);
     $children = $instance->children($mockFile);
     $this->assertEquals(2, count($children));
 }