aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-06-29 06:51:49 +0200
committerGitHub <noreply@github.com>2018-06-29 06:51:49 +0200
commit89b6ee1a45f165346ddcc9120195714087287b47 (patch)
treea7951e212e099f08cd28b412aaa03b1fe1757523 /tests
parente6780c4fc7fe0bb6ee6d2a8d4bfb2ca09d6e726a (diff)
parentab43251a45f9b04a1681a0b206d85676232dd7c3 (diff)
downloadnextcloud-server-89b6ee1a45f165346ddcc9120195714087287b47.tar.gz
nextcloud-server-89b6ee1a45f165346ddcc9120195714087287b47.zip
Merge pull request #9773 from nextcloud/feature/noid/resource_booking
resource booking
Diffstat (limited to 'tests')
-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());
+ }
+}