Ejemplo n.º 1
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);
 }
Ejemplo n.º 2
0
 public function testDelete()
 {
     $id = 5;
     $user = '******';
     $folder = new Folder();
     $folder->setId($id);
     $this->mapper->expects($this->once())->method('delete')->with($this->equalTo($folder));
     $this->mapper->expects($this->once())->method('find')->with($this->equalTo($id), $this->equalTo($user))->will($this->returnValue($folder));
     $this->newsService->delete($id, $user);
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 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());
 }
Ejemplo n.º 5
0
 public function __construct(array $defaults = [])
 {
     parent::__construct();
     $defaults = array_merge(['parentId' => 0, 'name' => 'folder', 'userId' => 'test', 'opened' => true, 'deletedAt' => 0], $defaults);
     unset($defaults['feeds']);
     $this->fillDefaults($defaults);
 }
Ejemplo n.º 6
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.º 7
0
 public function testPurgeDeletedNoInterval()
 {
     $folder1 = new Folder();
     $folder1->setId(3);
     $folder2 = new Folder();
     $folder2->setId(5);
     $feeds = [$folder1, $folder2];
     $this->folderMapper->expects($this->once())->method('getToDelete')->with($this->equalTo(null), $this->equalTo($this->user))->will($this->returnValue($feeds));
     $this->folderMapper->expects($this->at(1))->method('delete')->with($this->equalTo($folder1));
     $this->folderMapper->expects($this->at(2))->method('delete')->with($this->equalTo($folder2));
     $this->folderService->purgeDeleted($this->user, false);
 }