Пример #1
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);
 }
Пример #2
0
 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);
 }