Ejemplo n.º 1
0
 /**
  * Creates a new folder
  * @param string $folderName the name of the folder
  * @param string $userId the name of the user for whom it should be created
  * @param int $parentId the parent folder id, deprecated we don't nest
  * folders
  * @throws ServiceConflictException if name exists already
  * @throws ServiceValidationException if the folder has invalid parameters
  * @return Folder the newly created folder
  */
 public function create($folderName, $userId, $parentId = 0)
 {
     $this->validateFolder($folderName, $userId);
     $folder = new Folder();
     $folder->setName($folderName);
     $folder->setUserId($userId);
     $folder->setParentId($parentId);
     $folder->setOpened(true);
     return $this->folderMapper->insert($folder);
 }
Ejemplo n.º 2
0
 public function testCreate()
 {
     $folder = new Folder();
     $folder->setName('hey');
     $folder->setParentId(5);
     $folder->setUserId('john');
     $folder->setOpened(true);
     $this->folderMapper->expects($this->once())->method('insert')->with($this->equalTo($folder))->will($this->returnValue($folder));
     $result = $this->folderService->create('hey', 'john', 5);
     $this->assertEquals($folder, $result);
 }
Ejemplo n.º 3
0
 private function createFolder($folder)
 {
     $newFolder = new Folder();
     $newFolder->setName($folder['name']);
     $newFolder->setUserId($this->userId);
     $newFolder->setParentId(0);
     $newFolder->setOpened($folder['opened']);
     $newFolder->setDeletedAt($folder['deletedAt']);
     return $this->folderMapper->insert($newFolder);
 }