コード例 #1
0
ファイル: filesplugin.php プロジェクト: quality123/core
 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
 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]));
 }
コード例 #3
0
 /**
  * Test delete property
  */
 public function testDeleteProperty()
 {
     $node = $this->createTestNode('\\OCA\\DAV\\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
ファイル: systemtagplugin.php プロジェクト: kenwi/core
 /**
  * @dataProvider nodeClassProvider
  * @expectedException Sabre\DAV\Exception\Conflict
  */
 public function testCreateTagConflict($nodeClass)
 {
     $requestData = json_encode(['name' => 'Test', 'userVisible' => true, 'userAssignable' => false]);
     $node = $this->getMockBuilder($nodeClass)->disableOriginalConstructor()->getMock();
     $this->tagManager->expects($this->once())->method('createTag')->with('Test', true, false)->will($this->throwException(new TagAlreadyExistsException('Tag already exists')));
     $this->tree->expects($this->any())->method('getNodeForPath')->with('/systemtags')->will($this->returnValue($node));
     $request = $this->getMockBuilder('Sabre\\HTTP\\RequestInterface')->disableOriginalConstructor()->getMock();
     $response = $this->getMockBuilder('Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $request->expects($this->once())->method('getPath')->will($this->returnValue('/systemtags'));
     $request->expects($this->once())->method('getBodyAsString')->will($this->returnValue($requestData));
     $request->expects($this->once())->method('getHeader')->with('Content-Type')->will($this->returnValue('application/json'));
     $this->plugin->httpPost($request, $response);
 }
コード例 #5
0
 public function testOnReport()
 {
     $path = 'comments/files/42';
     $parameters = [['name' => '{http://owncloud.org/ns}limit', 'value' => 5], ['name' => '{http://owncloud.org/ns}offset', 'value' => 10], ['name' => '{http://owncloud.org/ns}datetime', 'value' => '2016-01-10 18:48:00']];
     $node = $this->getMockBuilder('\\OCA\\DAV\\Comments\\EntityCollection')->disableOriginalConstructor()->getMock();
     $node->expects($this->once())->method('findChildren')->with(5, 10, new \DateTime($parameters[2]['value']))->will($this->returnValue([]));
     $response = $this->getMockBuilder('Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $response->expects($this->once())->method('setHeader')->with('Content-Type', 'application/xml; charset=utf-8');
     $response->expects($this->once())->method('setStatus')->with(207);
     $response->expects($this->once())->method('setBody');
     $this->tree->expects($this->any())->method('getNodeForPath')->with('/' . $path)->will($this->returnValue($node));
     $this->server->expects($this->any())->method('getRequestUri')->will($this->returnValue($path));
     $this->server->httpResponse = $response;
     $this->plugin->initialize($this->server);
     $this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, $parameters, '/' . $path);
 }
コード例 #6
0
ファイル: filesreportplugin.php プロジェクト: gvde/core
 public function testOnReport()
 {
     $path = 'test';
     $parameters = [['name' => '{DAV:}prop', 'value' => [['name' => '{DAV:}getcontentlength', 'value' => ''], ['name' => '{http://owncloud.org/ns}size', 'value' => '']]], ['name' => '{http://owncloud.org/ns}filter-rules', 'value' => [['name' => '{http://owncloud.org/ns}systemtag', 'value' => '123'], ['name' => '{http://owncloud.org/ns}systemtag', 'value' => '456']]]];
     $this->groupManager->expects($this->any())->method('isAdmin')->will($this->returnValue(true));
     $this->tagMapper->expects($this->at(0))->method('getObjectIdsForTags')->with('123', 'files')->will($this->returnValue(['111', '222']));
     $this->tagMapper->expects($this->at(1))->method('getObjectIdsForTags')->with('456', 'files')->will($this->returnValue(['111', '222', '333']));
     $reportTargetNode = $this->getMockBuilder('\\OCA\\DAV\\Connector\\Sabre\\Directory')->disableOriginalConstructor()->getMock();
     $response = $this->getMockBuilder('Sabre\\HTTP\\ResponseInterface')->disableOriginalConstructor()->getMock();
     $response->expects($this->once())->method('setHeader')->with('Content-Type', 'application/xml; charset=utf-8');
     $response->expects($this->once())->method('setStatus')->with(207);
     $response->expects($this->once())->method('setBody');
     $this->tree->expects($this->any())->method('getNodeForPath')->with('/' . $path)->will($this->returnValue($reportTargetNode));
     $filesNode1 = $this->getMockBuilder('\\OCP\\Files\\Folder')->disableOriginalConstructor()->getMock();
     $filesNode2 = $this->getMockBuilder('\\OCP\\Files\\File')->disableOriginalConstructor()->getMock();
     $this->userFolder->expects($this->at(0))->method('getById')->with('111')->will($this->returnValue([$filesNode1]));
     $this->userFolder->expects($this->at(1))->method('getById')->with('222')->will($this->returnValue([$filesNode2]));
     $this->server->expects($this->any())->method('getRequestUri')->will($this->returnValue($path));
     $this->server->httpResponse = $response;
     $this->plugin->initialize($this->server);
     $this->plugin->onReport(FilesReportPluginImplementation::REPORT_NAME, $parameters, '/' . $path);
 }