/**
  * @covers RI\FileManagerBundle\Model\Selection\DeleteSelectionModel::delete
  * @covers RI\FileManagerBundle\Model\Selection\DeleteSelectionModel::getRemovedFiles
  */
 public function testGetRemovedFiles_ShouldReturnTrue()
 {
     $this->setMocks();
     $this->fileRepositoryMock->expects($this->once())->method('find')->with(self::FILE_ID_1)->will($this->returnValue($this->files[self::FILE_ID_1]));
     $this->directoryRepositoryMock->expects($this->once())->method('find')->with(self::DIR_ID_1_1)->will($this->returnValue($this->directories[self::DIR_ID_1_1]));
     $this->fileRepositoryMock->expects($this->once())->method('fetchFromDir')->with($this->directories[self::DIR_ID_1_1])->will($this->returnValue(array()));
     $this->entityManagerMock->expects($this->exactly(2))->method('remove');
     $this->deleteSelectionModel->delete(array(self::FILE_ID_1), array(self::DIR_ID_1_1));
     $this->assertEquals(array($this->files[self::FILE_ID_1]->getPath()), $this->deleteSelectionModel->getRemovedFiles());
 }
Ejemplo n.º 2
0
 /**
  * @covers RI\FileManagerBundle\Model\Selection\MoveSelectionModel::__construct
  * @covers RI\FileManagerBundle\Model\Selection\MoveSelectionModel::move
  * @covers RI\FileManagerBundle\Model\Selection\MoveSelectionModel::getDirectoryById
  * @covers RI\FileManagerBundle\Model\Selection\MoveSelectionModel::getFileById
  */
 public function testMove_ShouldReturnTrue()
 {
     $this->setMocks();
     $this->directoryRepositoryMock->expects($this->at(0))->method('find')->with(self::DIR_ID_1)->will($this->returnValue($this->directories[self::DIR_ID_1]));
     $this->directoryRepositoryMock->expects($this->at(1))->method('find')->with(self::DIR_ID_2)->will($this->returnValue($this->directories[self::DIR_ID_2]));
     $this->fileRepositoryMock->expects($this->at(0))->method('find')->with(self::FILE_ID_1)->will($this->returnValue($this->files[self::FILE_ID_1]));
     $this->fileRepositoryMock->expects($this->at(1))->method('find')->with(self::FILE_ID_2)->will($this->returnValue($this->files[self::FILE_ID_2]));
     $this->directoryDataProviderMock->expects($this->once())->method('getDirectoryParentsList')->with($this->directories[self::DIR_ID_1])->will($this->returnValue(array()));
     $result = $this->moveSelectionModel->move(self::DIR_ID_1, array(self::FILE_ID_1, self::FILE_ID_2), array(self::DIR_ID_2));
     $this->assertTrue($result);
     $this->assertEquals($this->directories[self::DIR_ID_1], $this->files[self::FILE_ID_1]->getDirectory());
     $this->assertEquals($this->directories[self::DIR_ID_1], $this->files[self::FILE_ID_2]->getDirectory());
     $this->assertEquals($this->directories[self::DIR_ID_1], $this->directories[self::DIR_ID_2]->getParent());
 }
Ejemplo n.º 3
0
 /**
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::copy
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::copyFolders
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::getDirectoryById
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::getFileById
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::copyFiles
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::copyFile
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::copyFileOnDisk
  * @covers RI\FileManagerBundle\Model\Selection\CopySelectionModel::copyFolderRecursive
  */
 public function testCopy_ShouldReturnTrue()
 {
     $this->setMocks();
     $this->directoryDataProviderMock->expects($this->once())->method('getDirectoryParentsList')->with($this->directories[self::DIR_ID_1])->will($this->returnValue(array()));
     $this->directoryRepositoryMock->expects($this->at(0))->method('find')->with(self::DIR_ID_1)->will($this->returnValue($this->directories[self::DIR_ID_1]));
     $this->directoryRepositoryMock->expects($this->at(1))->method('find')->with(self::DIR_ID_2)->will($this->returnValue($this->directories[self::DIR_ID_2]));
     $this->fileRepositoryMock->expects($this->at(0))->method('fetchFromDir')->with($this->directories[self::DIR_ID_2])->will($this->returnValue($this->files[self::FILE_ID_2]));
     $this->fileRepositoryMock->expects($this->at(1))->method('find')->with(self::FILE_ID_1)->will($this->returnValue($this->files[self::FILE_ID_1]));
     $this->fileRepositoryMock->expects($this->at(2))->method('find')->with(self::FILE_ID_2)->will($this->returnValue($this->files[self::FILE_ID_2]));
     $this->entityManagerMock->expects($this->any())->method('persist');
     $this->uploadDirectoryManagerMock->expects($this->at(0))->method('getNewPath')->with('abc.jpg')->will($this->returnValue('/../../web/abc_1.jpg'));
     $this->uploadDirectoryManagerMock->expects($this->at(1))->method('getAbsoluteUploadDir')->will($this->returnValue(__DIR__));
     $this->uploadDirectoryManagerMock->expects($this->at(2))->method('getNewPath')->with('xyz.jpg')->will($this->returnValue('/../../web/xyz_1.jpg'));
     $this->uploadDirectoryManagerMock->expects($this->at(3))->method('getAbsoluteUploadDir')->will($this->returnValue(__DIR__));
     $result = $this->CopySelectionModel->copy(self::DIR_ID_1, array(self::FILE_ID_1, self::FILE_ID_2), array(self::DIR_ID_2));
     $this->assertTrue($result);
 }