summaryrefslogtreecommitdiffstats
path: root/tests/lib/Calendar
diff options
context:
space:
mode:
authorGeorg Ehrke <developer@georgehrke.com>2018-06-19 12:22:30 +0200
committerGeorg Ehrke <developer@georgehrke.com>2018-06-25 04:59:04 +0200
commitcba783f5df8b0129d6b95056ef299e504fed4094 (patch)
tree0d9744ee201a041822277607181e8d81e3d04d63 /tests/lib/Calendar
parentda533d747088633535e5d5281da433753d3cfc81 (diff)
downloadnextcloud-server-cba783f5df8b0129d6b95056ef299e504fed4094.tar.gz
nextcloud-server-cba783f5df8b0129d6b95056ef299e504fed4094.zip
Calendar resource booking: unit tests / adding missing annotations
Signed-off-by: Georg Ehrke <developer@georgehrke.com>
Diffstat (limited to 'tests/lib/Calendar')
-rw-r--r--tests/lib/Calendar/Resource/ManagerTest.php94
-rw-r--r--tests/lib/Calendar/Room/ManagerTest.php94
2 files changed, 188 insertions, 0 deletions
diff --git a/tests/lib/Calendar/Resource/ManagerTest.php b/tests/lib/Calendar/Resource/ManagerTest.php
new file mode 100644
index 00000000000..ccc6bbf182b
--- /dev/null
+++ b/tests/lib/Calendar/Resource/ManagerTest.php
@@ -0,0 +1,94 @@
+<?php
+/**
+ * @copyright 2018, 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 Test\Calendar\Resource;
+
+use \OC\Calendar\Resource\Manager;
+use \OCP\Calendar\Resource\IBackend;
+use \Test\TestCase;
+
+class ManagerTest extends TestCase {
+
+ /** @var Manager */
+ private $manager;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->manager = new Manager();
+ }
+
+ public function testRegisterUnregisterBackend() {
+ $backend1 = $this->createMock(IBackend::class);
+ $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+
+ $backend2 = $this->createMock(IBackend::class);
+ $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+
+ $this->manager->registerBackend($backend1);
+ $this->manager->registerBackend($backend2);
+
+ $this->assertEquals([
+ $backend1, $backend2
+ ], $this->manager->getBackends());
+
+ $this->manager->unregisterBackend($backend1);
+
+ $this->assertEquals([
+ $backend2
+ ], $this->manager->getBackends());
+ }
+
+ public function testGetBackend() {
+ $backend1 = $this->createMock(IBackend::class);
+ $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+
+ $backend2 = $this->createMock(IBackend::class);
+ $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+
+ $this->manager->registerBackend($backend1);
+ $this->manager->registerBackend($backend2);
+
+ $this->assertEquals($backend1, $this->manager->getBackend('backend_1'));
+ $this->assertEquals($backend2, $this->manager->getBackend('backend_2'));
+ }
+
+ public function testClear() {
+ $backend1 = $this->createMock(IBackend::class);
+ $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+
+ $backend2 = $this->createMock(IBackend::class);
+ $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+
+ $this->manager->registerBackend($backend1);
+ $this->manager->registerBackend($backend2);
+
+ $this->assertEquals([
+ $backend1, $backend2
+ ], $this->manager->getBackends());
+
+ $this->manager->clear();
+
+ $this->assertEquals([], $this->manager->getBackends());
+ }
+}
diff --git a/tests/lib/Calendar/Room/ManagerTest.php b/tests/lib/Calendar/Room/ManagerTest.php
new file mode 100644
index 00000000000..34d69d127e2
--- /dev/null
+++ b/tests/lib/Calendar/Room/ManagerTest.php
@@ -0,0 +1,94 @@
+<?php
+/**
+ * @copyright 2018, 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 Test\Calendar\Room;
+
+use \OC\Calendar\Room\Manager;
+use \OCP\Calendar\Room\IBackend;
+use \Test\TestCase;
+
+class ManagerTest extends TestCase {
+
+ /** @var Manager */
+ private $manager;
+
+ protected function setUp() {
+ parent::setUp();
+
+ $this->manager = new Manager();
+ }
+
+ public function testRegisterUnregisterBackend() {
+ $backend1 = $this->createMock(IBackend::class);
+ $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+
+ $backend2 = $this->createMock(IBackend::class);
+ $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+
+ $this->manager->registerBackend($backend1);
+ $this->manager->registerBackend($backend2);
+
+ $this->assertEquals([
+ $backend1, $backend2
+ ], $this->manager->getBackends());
+
+ $this->manager->unregisterBackend($backend1);
+
+ $this->assertEquals([
+ $backend2
+ ], $this->manager->getBackends());
+ }
+
+ public function testGetBackend() {
+ $backend1 = $this->createMock(IBackend::class);
+ $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+
+ $backend2 = $this->createMock(IBackend::class);
+ $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+
+ $this->manager->registerBackend($backend1);
+ $this->manager->registerBackend($backend2);
+
+ $this->assertEquals($backend1, $this->manager->getBackend('backend_1'));
+ $this->assertEquals($backend2, $this->manager->getBackend('backend_2'));
+ }
+
+ public function testClear() {
+ $backend1 = $this->createMock(IBackend::class);
+ $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1'));
+
+ $backend2 = $this->createMock(IBackend::class);
+ $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2'));
+
+ $this->manager->registerBackend($backend1);
+ $this->manager->registerBackend($backend2);
+
+ $this->assertEquals([
+ $backend1, $backend2
+ ], $this->manager->getBackends());
+
+ $this->manager->clear();
+
+ $this->assertEquals([], $this->manager->getBackends());
+ }
+}