diff options
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/AppInfo/PluginManagerTest.php | 104 | ||||
-rw-r--r-- | apps/dav/tests/unit/ServerTest.php | 4 | ||||
-rw-r--r-- | apps/dav/tests/unit/Settings/CalDAVSettingsTest.php | 58 |
3 files changed, 164 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); } diff --git a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php new file mode 100644 index 00000000000..8ee58107487 --- /dev/null +++ b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php @@ -0,0 +1,58 @@ +<?php +/** + * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com> + * + * @author Georg Ehrke <oc.list@georgehrke.com> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * 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 + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +namespace OCA\DAV\Tests\Unit\DAV\Settings; + +use OCA\DAV\Settings\CalDAVSettings; +use OCP\IConfig; +use Test\TestCase; + +class CalDAVSettingsTest extends TestCase { + + /** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */ + private $config; + + /** @var CalDAVSettings */ + private $settings; + + public function setUp() { + parent::setUp(); + + $this->config = $this->createMock(IConfig::class); + $this->settings = new CalDAVSettings($this->config); + } + + public function testGetForm() { + $result = $this->settings->getForm(); + + $this->assertInstanceOf('OCP\AppFramework\Http\TemplateResponse', $result); + } + + public function testGetSection() { + $this->assertEquals('additional', $this->settings->getSection()); + } + + public function testGetPriority() { + $this->assertEquals(20, $this->settings->getPriority()); + } +} |