Пример #1
0
 /**
  * @test
  */
 public function findManyDelegates()
 {
     $arr = array('tus', 'lus');
     $class = 'Xi\\Filelib\\File\\File';
     $file = File::create();
     $this->adapter->expects($this->once())->method('findByIds')->with($arr, $class)->will($this->returnValue(array($file)));
     $request = new FindByIdsRequest($arr, $class);
     $ret = $this->cache->findByIds($request);
     $this->assertEquals(ArrayCollection::create(array($file)), $ret->getResult());
 }
Пример #2
0
 /**
  * @test
  */
 public function deleteFolderShouldThrowExceptionWhenFolderContainsFiles()
 {
     $this->setExpectedException('Xi\\Filelib\\Backend\\FolderNotEmptyException');
     $files = array(File::create(array('id' => 1)), File::create(array('id' => 2)));
     $obj = Folder::create(array('id' => 1, 'parent_id' => 66));
     $this->platform->expects($this->never())->method('deleteFolder');
     $this->im->expects($this->never())->method('remove');
     $backend = $this->getMockBuilder('Xi\\Filelib\\Backend\\Backend')->setConstructorArgs(array($this->ed, $this->platform, $this->im))->setMethods(array('findByFinder'))->getMock();
     $self = $this;
     $backend->expects($this->once())->method('findByFinder')->with($this->isInstanceOf('Xi\\Filelib\\Backend\\Finder\\FileFinder'))->will($this->returnCallback(function (FileFinder $finder) use($self, $files) {
         $expectedParams = array('folder_id' => 1);
         $self->assertEquals($expectedParams, $finder->getParameters());
         return ArrayCollection::create($files);
     }));
     $ret = $backend->deleteFolder($obj);
     $this->assertNull($ret);
 }
Пример #3
0
 /**
  * @return ArrayCollection
  */
 public function getResult()
 {
     return ArrayCollection::create($this->foundObjects);
 }
Пример #4
0
 /**
  * @return ArrayCollection
  */
 public function getPlugins()
 {
     return ArrayCollection::create($this->plugins);
 }
Пример #5
0
 /**
  * Returns all file profiles
  *
  * @return ArrayCollection
  */
 public function getProfiles()
 {
     return ArrayCollection::create($this->profiles);
 }
Пример #6
0
 /**
  * @test
  */
 public function removeManyDeletesAllObjectsAndRewindsIterator()
 {
     $first = File::create(array('id' => 6));
     $array = array($first, Folder::create(array('id' => 6)), File::create(array('id' => 6)));
     $iter = ArrayCollection::create($array);
     $im = $this->getMockBuilder('Xi\\Filelib\\Backend\\IdentityMap\\IdentityMap')->setMethods(array('remove'))->disableOriginalConstructor()->getMock();
     $im->expects($this->exactly(3))->method('remove')->with($this->isInstanceOf('Xi\\Filelib\\Identifiable'));
     $im->removeMany($iter);
     $this->assertSame($first, $iter->first());
 }