示例#1
0
 public function testPrepareResponses()
 {
     $requestedProps = ['{DAV:}getcontentlength', '{http://owncloud.org/ns}fileid', '{DAV:}resourcetype'];
     $node1 = $this->getMockBuilder('\\OCA\\DAV\\Connector\\Sabre\\Directory')->disableOriginalConstructor()->getMock();
     $node2 = $this->getMockBuilder('\\OCA\\DAV\\Connector\\Sabre\\File')->disableOriginalConstructor()->getMock();
     $node1->expects($this->once())->method('getInternalFileId')->will($this->returnValue('111'));
     $node2->expects($this->once())->method('getInternalFileId')->will($this->returnValue('222'));
     $node2->expects($this->once())->method('getSize')->will($this->returnValue(1024));
     $this->server->addPlugin(new \OCA\DAV\Connector\Sabre\FilesPlugin($this->tree, $this->view));
     $this->plugin->initialize($this->server);
     $responses = $this->plugin->prepareResponses($requestedProps, [$node1, $node2]);
     $this->assertCount(2, $responses);
     $this->assertEquals(200, $responses[0]->getHttpStatus());
     $this->assertEquals(200, $responses[1]->getHttpStatus());
     $props1 = $responses[0]->getResponseProperties();
     $this->assertEquals('111', $props1[200]['{http://owncloud.org/ns}fileid']);
     $this->assertNull($props1[404]['{DAV:}getcontentlength']);
     $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\ResourceType', $props1[200]['{DAV:}resourcetype']);
     $resourceType1 = $props1[200]['{DAV:}resourcetype']->getValue();
     $this->assertEquals('{DAV:}collection', $resourceType1[0]);
     $props2 = $responses[1]->getResponseProperties();
     $this->assertEquals('1024', $props2[200]['{DAV:}getcontentlength']);
     $this->assertEquals('222', $props2[200]['{http://owncloud.org/ns}fileid']);
     $this->assertInstanceOf('\\Sabre\\DAV\\Xml\\Property\\ResourceType', $props2[200]['{DAV:}resourcetype']);
     $this->assertCount(0, $props2[200]['{DAV:}resourcetype']->getValue());
 }
示例#2
0
 public function testProcessFilterRulesVisibleTagAsUser()
 {
     $this->groupManager->expects($this->any())->method('isAdmin')->will($this->returnValue(false));
     $tag1 = $this->getMock('\\OCP\\SystemTag\\ISystemTag');
     $tag1->expects($this->any())->method('getId')->will($this->returnValue('123'));
     $tag1->expects($this->any())->method('isUserVisible')->will($this->returnValue(true));
     $tag2 = $this->getMock('\\OCP\\SystemTag\\ISystemTag');
     $tag2->expects($this->any())->method('getId')->will($this->returnValue('123'));
     $tag2->expects($this->any())->method('isUserVisible')->will($this->returnValue(true));
     $this->tagManager->expects($this->once())->method('getTagsByIds')->with(['123', '456'])->will($this->returnValue([$tag1, $tag2]));
     $this->tagMapper->expects($this->at(0))->method('getObjectIdsForTags')->with('123')->will($this->returnValue(['111', '222']));
     $this->tagMapper->expects($this->at(1))->method('getObjectIdsForTags')->with('456')->will($this->returnValue(['222', '333']));
     $rules = [['name' => '{http://owncloud.org/ns}systemtag', 'value' => '123'], ['name' => '{http://owncloud.org/ns}systemtag', 'value' => '456']];
     $this->assertEquals(['222'], array_values($this->plugin->processFilterRules($rules)));
 }