Example #1
0
 /**
  * Set site representative image
  *
  * @param Image $image image instance
  * @return void
  */
 public function setSiteImage(Image $image)
 {
     $this->storage->removeAll($this->get('uuid'));
     $this->storage->bind($this->get('uuid'), $image->getFile());
     $this->image = $image;
 }
 public function testRemoveAll()
 {
     list($handler, $repo, $auth, $keygen) = $this->getMocks();
     $mockFile1 = m::mock('Xpressengine\\Storage\\File');
     $mockFile1->id = 'fileidstring1';
     $mockFile1->use_count = 2;
     $mockFile2 = m::mock('Xpressengine\\Storage\\File');
     $mockFile2->id = 'fileidstring2';
     $mockFile2->use_count = 2;
     $repo->shouldReceive('fetchByTargetId')->once()->with('targetidstring')->andReturn([$mockFile1, $mockFile2]);
     $repo->shouldReceive('unRelating')->once()->with('targetidstring', 'fileidstring1')->andReturnNull();
     $repo->shouldReceive('unRelating')->once()->with('targetidstring', 'fileidstring2')->andReturnNull();
     $repo->shouldReceive('fetch')->once()->with(['parentId' => 'fileidstring1'])->andReturn([]);
     $repo->shouldReceive('fetch')->once()->with(['parentId' => 'fileidstring2'])->andReturn([]);
     $repo->shouldReceive('delete')->once()->with($mockFile1)->andReturnNull();
     $repo->shouldReceive('delete')->once()->with($mockFile2)->andReturnNull();
     $handler->shouldReceive('delete')->once()->with($mockFile1)->andReturnNull();
     $handler->shouldReceive('delete')->once()->with($mockFile2)->andReturnNull();
     $instance = new Storage($handler, $repo, $auth, $keygen);
     $instance->removeAll('targetidstring');
 }