示例#1
0
 public function testUpdateFav()
 {
     // this test will replace the existing tags "tagremove" with "tag1" and "tag2"
     // and keep "tagkeep"
     $node = $this->getMockBuilder('\\OCA\\DAV\\Connector\\Sabre\\Node')->disableOriginalConstructor()->getMock();
     $node->expects($this->any())->method('getId')->will($this->returnValue(123));
     $this->tree->expects($this->any())->method('getNodeForPath')->with('/dummypath')->will($this->returnValue($node));
     // set favorite tag
     $this->tagger->expects($this->once())->method('tagAs')->with(123, self::TAG_FAVORITE);
     // properties to set
     $propPatch = new \Sabre\DAV\PropPatch(array(self::FAVORITE_PROPERTYNAME => true));
     $this->plugin->handleUpdateProperties('/dummypath', $propPatch);
     $propPatch->commit();
     // all requested properties removed, as they were processed already
     $this->assertEmpty($propPatch->getRemainingMutations());
     $result = $propPatch->getResult();
     $this->assertFalse(false, isset($result[self::TAGS_PROPERTYNAME]));
     $this->assertEquals(200, isset($result[self::FAVORITE_PROPERTYNAME]));
     // unfavorite now
     // set favorite tag
     $this->tagger->expects($this->once())->method('unTag')->with(123, self::TAG_FAVORITE);
     // properties to set
     $propPatch = new \Sabre\DAV\PropPatch(array(self::FAVORITE_PROPERTYNAME => false));
     $this->plugin->handleUpdateProperties('/dummypath', $propPatch);
     $propPatch->commit();
     // all requested properties removed, as they were processed already
     $this->assertEmpty($propPatch->getRemainingMutations());
     $result = $propPatch->getResult();
     $this->assertFalse(false, isset($result[self::TAGS_PROPERTYNAME]));
     $this->assertEquals(200, isset($result[self::FAVORITE_PROPERTYNAME]));
 }
 public function testUpdateProperties()
 {
     $systemTag = new SystemTag(1, 'Test', true, false);
     $node = $this->getMockBuilder('\\OCA\\DAV\\SystemTag\\SystemTagNode')->disableOriginalConstructor()->getMock();
     $node->expects($this->any())->method('getSystemTag')->will($this->returnValue($systemTag));
     $this->tree->expects($this->any())->method('getNodeForPath')->with('/systemtag/1')->will($this->returnValue($node));
     $node->expects($this->once())->method('update')->with('Test changed', false, true);
     // properties to set
     $propPatch = new \Sabre\DAV\PropPatch(array(self::DISPLAYNAME_PROPERTYNAME => 'Test changed', self::USERVISIBLE_PROPERTYNAME => 0, self::USERASSIGNABLE_PROPERTYNAME => 1));
     $this->plugin->handleUpdateProperties('/systemtag/1', $propPatch);
     $propPatch->commit();
     // all requested properties removed, as they were processed already
     $this->assertEmpty($propPatch->getRemainingMutations());
     $result = $propPatch->getResult();
     $this->assertEquals(200, $result[self::DISPLAYNAME_PROPERTYNAME]);
     $this->assertEquals(200, $result[self::USERASSIGNABLE_PROPERTYNAME]);
     $this->assertEquals(200, $result[self::USERVISIBLE_PROPERTYNAME]);
 }