summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests
diff options
context:
space:
mode:
authorLukas Reschke <lukas@statuscode.ch>2017-10-19 11:09:12 +0200
committerGitHub <noreply@github.com>2017-10-19 11:09:12 +0200
commit3a3e6c34d04324b52464c37e7b638ecd7256812a (patch)
treeb6c6a1b821355fb33ff959b1b8d3bbc6629d4ce7 /apps/dav/tests
parentf6f7b50cf0156673f92c7e00ebacf0fbfd6e98c1 (diff)
parent79c4538511206c2f64dfdcbe030bbbe166125ae4 (diff)
downloadnextcloud-server-3a3e6c34d04324b52464c37e7b638ecd7256812a.tar.gz
nextcloud-server-3a3e6c34d04324b52464c37e7b638ecd7256812a.zip
Merge pull request #6835 from nextcloud/dav-plugins-from-apps-only
Let apps register Sabre plugins or collections (v2)
Diffstat (limited to 'apps/dav/tests')
-rw-r--r--apps/dav/tests/unit/AppInfo/PluginManagerTest.php104
-rw-r--r--apps/dav/tests/unit/ServerTest.php4
2 files changed, 106 insertions, 2 deletions
diff --git a/apps/dav/tests/unit/AppInfo/PluginManagerTest.php b/apps/dav/tests/unit/AppInfo/PluginManagerTest.php
new file mode 100644
index 00000000000..5776b939123
--- /dev/null
+++ b/apps/dav/tests/unit/AppInfo/PluginManagerTest.php
@@ -0,0 +1,104 @@
+<?php
+/**
+ * @author Vincent Petry <pvince81@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud GmbH.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\DAV\Tests\unit\AppInfo;
+
+use Test\TestCase;
+use OCP\App\IAppManager;
+use OC\ServerContainer;
+use OCA\DAV\AppInfo\PluginManager;
+
+/**
+ * Class PluginManagerTest
+ *
+ * @package OCA\DAV\Tests\Unit\AppInfo
+ */
+class PluginManagerTest extends TestCase {
+ public function test() {
+ $server = $this->createMock(ServerContainer::class);
+
+
+ $appManager = $this->createMock(IAppManager::class);
+ $appManager->method('getInstalledApps')
+ ->willReturn(['adavapp', 'adavapp2']);
+
+ $appInfo1 = [
+ 'types' => ['dav'],
+ 'sabre' => [
+ 'plugins' => [
+ 'plugin' => [
+ '\OCA\DAV\ADavApp\PluginOne',
+ '\OCA\DAV\ADavApp\PluginTwo',
+ ],
+ ],
+ 'collections' => [
+ 'collection' => [
+ '\OCA\DAV\ADavApp\CollectionOne',
+ '\OCA\DAV\ADavApp\CollectionTwo',
+ ]
+ ],
+ ],
+ ];
+ $appInfo2 = [
+ 'types' => ['logging', 'dav'],
+ 'sabre' => [
+ 'plugins' => [
+ 'plugin' => '\OCA\DAV\ADavApp2\PluginOne',
+ ],
+ 'collections' => [
+ 'collection' => '\OCA\DAV\ADavApp2\CollectionOne',
+ ],
+ ],
+ ];
+
+ $appManager->method('getAppInfo')
+ ->will($this->returnValueMap([
+ ['adavapp', $appInfo1],
+ ['adavapp2', $appInfo2],
+ ]));
+
+ $pluginManager = new PluginManager($server, $appManager);
+
+ $server->method('query')
+ ->will($this->returnValueMap([
+ ['\OCA\DAV\ADavApp\PluginOne', 'dummyplugin1'],
+ ['\OCA\DAV\ADavApp\PluginTwo', 'dummyplugin2'],
+ ['\OCA\DAV\ADavApp\CollectionOne', 'dummycollection1'],
+ ['\OCA\DAV\ADavApp\CollectionTwo', 'dummycollection2'],
+ ['\OCA\DAV\ADavApp2\PluginOne', 'dummy2plugin1'],
+ ['\OCA\DAV\ADavApp2\CollectionOne', 'dummy2collection1'],
+ ]));
+
+ $expectedPlugins = [
+ 'dummyplugin1',
+ 'dummyplugin2',
+ 'dummy2plugin1',
+ ];
+ $expectedCollections = [
+ 'dummycollection1',
+ 'dummycollection2',
+ 'dummy2collection1',
+ ];
+
+ $this->assertEquals($expectedPlugins, $pluginManager->getAppPlugins());
+ $this->assertEquals($expectedCollections, $pluginManager->getAppCollections());
+ }
+}
diff --git a/apps/dav/tests/unit/ServerTest.php b/apps/dav/tests/unit/ServerTest.php
index 19e75c7b24e..1b430b0f198 100644
--- a/apps/dav/tests/unit/ServerTest.php
+++ b/apps/dav/tests/unit/ServerTest.php
@@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit;
use OCA\DAV\Server;
use OCP\IRequest;
+use OCA\DAV\AppInfo\PluginManager;
/**
* Class ServerTest
@@ -38,8 +39,7 @@ class ServerTest extends \Test\TestCase {
public function test() {
/** @var IRequest $r */
- $r = $this->getMockBuilder('\OCP\IRequest')
- ->disableOriginalConstructor()->getMock();
+ $r = $this->createMock(IRequest::class);
$s = new Server($r, '/');
$this->assertInstanceOf('OCA\DAV\Server', $s);
}