public function testRename() { $folder = new Folder(); $folder->setName('jooohn'); $this->folderMapper->expects($this->once())->method('find')->with($this->equalTo(3))->will($this->returnValue($folder)); $this->folderMapper->expects($this->once())->method('update')->with($this->equalTo($folder)); $this->folderService->rename(3, 'bogus', ''); $this->assertEquals('bogus', $folder->getName()); }
/** * 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); }
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); }
public function testCreate() { $folderName = 'test'; $folder = new Folder(); $folder->setName($folderName); $this->folderService->expects($this->once())->method('purgeDeleted')->with($this->equalTo($this->user), $this->equalTo(false)); $this->folderService->expects($this->once())->method('create')->with($this->equalTo($folderName), $this->equalTo($this->user))->will($this->returnValue($folder)); $response = $this->folderAPI->create($folderName); $this->assertEquals(['folders' => [$folder->toAPI()]], $response); }
public function testCreate() { $folderName = 'test'; $folder = new Folder(); $folder->setName($folderName); $folders = array($folder); $this->folderAPI = new FolderApiController($this->appName, $this->getRequest(array('params' => array('name' => $folderName))), $this->folderBusinessLayer, $this->itemBusinessLayer, $this->user); $this->folderBusinessLayer->expects($this->once())->method('purgeDeleted')->with($this->equalTo($this->user), $this->equalTo(false)); $this->folderBusinessLayer->expects($this->once())->method('create')->with($this->equalTo($folderName), $this->equalTo($this->user))->will($this->returnValue($folder)); $response = $this->folderAPI->create(); $this->assertEquals(array('folders' => array($folders[0]->toAPI())), $response->getData()); }