diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-10-21 09:44:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-21 09:44:15 +0200 |
commit | 2b76d14330b5e6712b10411b6f0a7628962550e5 (patch) | |
tree | 00972ca510dc99eefaf69951f19d15635a2f13ae /apps/dav/tests | |
parent | 50b6ee67cb025332f1ec7012d3705150ef5a165a (diff) | |
parent | 73e216e0a7db0a48d852c1cdc9fe7cc281f488cd (diff) | |
download | nextcloud-server-2b76d14330b5e6712b10411b6f0a7628962550e5.tar.gz nextcloud-server-2b76d14330b5e6712b10411b6f0a7628962550e5.zip |
Merge pull request #1834 from nextcloud/downstream-26186
Add more files plugins to new DAV endpoint
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index 2097777c8fd..2b5c9f46301 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -82,9 +82,13 @@ class FilesReportPluginTest extends \Test\TestCase { $this->server = $this->getMockBuilder('\Sabre\DAV\Server') ->setConstructorArgs([$this->tree]) - ->setMethods(['getRequestUri']) + ->setMethods(['getRequestUri', 'getBaseUri']) ->getMock(); + $this->server->expects($this->any()) + ->method('getBaseUri') + ->will($this->returnValue('http://example.com/owncloud/remote.php/dav')); + $this->groupManager = $this->getMockBuilder('\OCP\IGroupManager') ->disableOriginalConstructor() ->getMock(); @@ -129,9 +133,6 @@ class FilesReportPluginTest extends \Test\TestCase { ); } - /** - * @expectedException \Sabre\DAV\Exception\ReportNotSupported - */ public function testOnReportInvalidNode() { $path = 'totally/unrelated/13'; @@ -149,12 +150,9 @@ class FilesReportPluginTest extends \Test\TestCase { ->will($this->returnValue($path)); $this->plugin->initialize($this->server); - $this->plugin->onReport(FilesReportPluginImplementation::REPORT_NAME, [], '/' . $path); + $this->assertNull($this->plugin->onReport(FilesReportPluginImplementation::REPORT_NAME, [], '/' . $path)); } - /** - * @expectedException \Sabre\DAV\Exception\ReportNotSupported - */ public function testOnReportInvalidReportName() { $path = 'test'; @@ -172,7 +170,7 @@ class FilesReportPluginTest extends \Test\TestCase { ->will($this->returnValue($path)); $this->plugin->initialize($this->server); - $this->plugin->onReport('{whoever}whatever', [], '/' . $path); + $this->assertNull($this->plugin->onReport('{whoever}whatever', [], '/' . $path)); } public function testOnReport() { @@ -254,7 +252,7 @@ class FilesReportPluginTest extends \Test\TestCase { $this->server->httpResponse = $response; $this->plugin->initialize($this->server); - $this->plugin->onReport(FilesReportPluginImplementation::REPORT_NAME, $parameters, '/' . $path); + $this->assertFalse($this->plugin->onReport(FilesReportPluginImplementation::REPORT_NAME, $parameters, '/' . $path)); } public function testFindNodesByFileIdsRoot() { @@ -362,12 +360,18 @@ class FilesReportPluginTest extends \Test\TestCase { $node1->expects($this->once()) ->method('getInternalFileId') ->will($this->returnValue('111')); + $node1->expects($this->any()) + ->method('getPath') + ->will($this->returnValue('/node1')); $node2->expects($this->once()) ->method('getInternalFileId') ->will($this->returnValue('222')); $node2->expects($this->once()) ->method('getSize') ->will($this->returnValue(1024)); + $node2->expects($this->any()) + ->method('getPath') + ->will($this->returnValue('/sub/node2')); $config = $this->getMockBuilder('\OCP\IConfig') ->disableOriginalConstructor() @@ -385,13 +389,16 @@ class FilesReportPluginTest extends \Test\TestCase { ) ); $this->plugin->initialize($this->server); - $responses = $this->plugin->prepareResponses($requestedProps, [$node1, $node2]); + $responses = $this->plugin->prepareResponses('/files/username', $requestedProps, [$node1, $node2]); $this->assertCount(2, $responses); $this->assertEquals(200, $responses[0]->getHttpStatus()); $this->assertEquals(200, $responses[1]->getHttpStatus()); + $this->assertEquals('http://example.com/owncloud/remote.php/dav/files/username/node1', $responses[0]->getHref()); + $this->assertEquals('http://example.com/owncloud/remote.php/dav/files/username/sub/node2', $responses[1]->getHref()); + $props1 = $responses[0]->getResponseProperties(); $this->assertEquals('111', $props1[200]['{http://owncloud.org/ns}fileid']); $this->assertNull($props1[404]['{DAV:}getcontentlength']); @@ -671,4 +678,21 @@ class FilesReportPluginTest extends \Test\TestCase { $this->assertEquals(['456', '789'], array_values($this->invokePrivate($this->plugin, 'processFilterRules', [$rules]))); } + + public function filesBaseUriProvider() { + return [ + ['', '', ''], + ['files/username', '', '/files/username'], + ['files/username/test', '/test', '/files/username'], + ['files/username/test/sub', '/test/sub', '/files/username'], + ['test', '/test', ''], + ]; + } + + /** + * @dataProvider filesBaseUriProvider + */ + public function testFilesBaseUri($uri, $reportPath, $expectedUri) { + $this->assertEquals($expectedUri, $this->invokePrivate($this->plugin, 'getFilesBaseUri', [$uri, $reportPath])); + } } |