示例#1
0
	private function createTestNode($class) {
		$node = $this->getMockBuilder($class)
			->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));

		$node->expects($this->any())
			->method('getFileId')
			->will($this->returnValue(123));
		$node->expects($this->any())
			->method('getEtag')
			->will($this->returnValue('"abc"'));
		$node->expects($this->any())
			->method('getDavPermissions')
			->will($this->returnValue('DWCKMSR'));

		return $node;
	}
示例#2
0
 function testTreeMove()
 {
     mkdir(SABRE_TEMPDIR . '/issue33');
     $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33');
     $dir->createDirectory('bar');
     $tree = new ObjectTree($dir);
     $tree->move('bar', urldecode('%C3%A0fo%C3%B3'));
     $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3'));
     $this->assertEquals(urldecode('%C3%A0fo%C3%B3'), $node->getName());
 }
	/**
	 * Test delete property
	 */
	public function testDeleteProperty() {
		$node = $this->createTestNode('\OC\Connector\Sabre\File');
		$this->tree->expects($this->any())
			->method('getNodeForPath')
			->with('/dummypath')
			->will($this->returnValue($node));

		$this->applyDefaultProps();

		$propPatch = new \Sabre\DAV\PropPatch(array(
			'customprop' => null,
		));

		$this->plugin->propPatch(
			'/dummypath',
			$propPatch
		);

		$propPatch->commit();

		$this->assertEmpty($propPatch->getRemainingMutations());

		$result = $propPatch->getResult();
		$this->assertEquals(204, $result['customprop']);
	}
示例#4
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]));
 }
 /**
  * @dataProvider tagsGetPropertiesDataProvider
  */
 public function testPreloadThenGetProperties($tags, $requestedProperties, $expectedProperties)
 {
     $node1 = $this->getMockBuilder('\\OC_Connector_Sabre_File')->disableOriginalConstructor()->getMock();
     $node1->expects($this->any())->method('getId')->will($this->returnValue(111));
     $node2 = $this->getMockBuilder('\\OC_Connector_Sabre_File')->disableOriginalConstructor()->getMock();
     $node2->expects($this->any())->method('getId')->will($this->returnValue(222));
     $expectedCallCount = 0;
     if (count($requestedProperties) > 0) {
         // this guarantees that getTagsForObjects
         // is only called once and then the tags
         // are cached
         $expectedCallCount = 1;
     }
     $node = $this->getMockBuilder('\\OC_Connector_Sabre_Directory')->disableOriginalConstructor()->getMock();
     $node->expects($this->any())->method('getId')->will($this->returnValue(123));
     $node->expects($this->exactly($expectedCallCount))->method('getChildren')->will($this->returnValue(array($node1, $node2)));
     $this->tree->expects($this->once())->method('getNodeForPath')->with('/subdir')->will($this->returnValue($node));
     $this->tagger->expects($this->exactly($expectedCallCount))->method('getTagsForObjects')->with($this->equalTo(array(111, 222)))->will($this->returnValue(array(111 => $tags, 123 => $tags)));
     $returnedProperties = array();
     $this->plugin->beforeGetPropertiesForPath('/subdir', $requestedProperties, 1);
     $this->plugin->beforeGetProperties('/subdir/test.txt', $node1, $requestedProperties, $returnedProperties);
     $this->assertEquals($expectedProperties, $returnedProperties);
 }
 /**
  * add vacation template file to vfs
  */
 protected function _addVacationTemplateFile()
 {
     $webdavRoot = new DAV\ObjectTree(new Tinebase_WebDav_Root());
     $path = '/webdav/Felamimail/shared/Vacation Templates';
     $node = $webdavRoot->getNodeForPath($path);
     $this->_pathsToDelete[] = $path . '/' . $this->_sieveVacationTemplateFile;
     $node->createFile($this->_sieveVacationTemplateFile, fopen(dirname(__FILE__) . '/../files/' . $this->_sieveVacationTemplateFile, 'r'));
 }