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]); }
/** * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testUpdatePropertiesForbidden() { $systemTag = new SystemTag(1, 'Test', true, false); $this->user->expects($this->any())->method('getUID')->willReturn('admin'); $this->groupManager->expects($this->any())->method('isAdmin')->with('admin')->willReturn(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->never())->method('update'); $this->tagManager->expects($this->never())->method('setTagGroups'); // properties to set $propPatch = new \Sabre\DAV\PropPatch(array(self::GROUPS_PROPERTYNAME => 'group1|group2')); $this->plugin->handleUpdateProperties('/systemtag/1', $propPatch); $propPatch->commit(); }