diff options
author | Morris Jobke <hey@morrisjobke.de> | 2018-10-08 17:00:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-08 17:00:50 +0200 |
commit | fe2a60082334f53d75411bd8c05928778afadc04 (patch) | |
tree | 0a4bcffd54c1f37ffb1a127e4a1314dc20fc1287 /tests | |
parent | 8110a3be699bbdea96df30472dce7862e0964901 (diff) | |
parent | 970242b6ca79a0dbb1ac1a868c7b82c7aa49bd8a (diff) | |
download | nextcloud-server-fe2a60082334f53d75411bd8c05928778afadc04.tar.gz nextcloud-server-fe2a60082334f53d75411bd8c05928778afadc04.zip |
Merge pull request #10839 from nextcloud/bugfix/10212/use_class_implementation
adjust Calendar resource / room interfaces to use class implementation
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Calendar/Resource/ManagerTest.php | 45 | ||||
-rw-r--r-- | tests/lib/Calendar/Room/ManagerTest.php | 45 |
2 files changed, 74 insertions, 16 deletions
diff --git a/tests/lib/Calendar/Resource/ManagerTest.php b/tests/lib/Calendar/Resource/ManagerTest.php index ccc6bbf182b..1d9229856db 100644 --- a/tests/lib/Calendar/Resource/ManagerTest.php +++ b/tests/lib/Calendar/Resource/ManagerTest.php @@ -25,6 +25,7 @@ namespace Test\Calendar\Resource; use \OC\Calendar\Resource\Manager; use \OCP\Calendar\Resource\IBackend; +use OCP\IServerContainer; use \Test\TestCase; class ManagerTest extends TestCase { @@ -32,27 +33,39 @@ class ManagerTest extends TestCase { /** @var Manager */ private $manager; + /** @var IServerContainer */ + private $server; + protected function setUp() { parent::setUp(); - $this->manager = new Manager(); + $this->server = $this->createMock(IServerContainer::class); + $this->manager = new Manager($this->server); } public function testRegisterUnregisterBackend() { $backend1 = $this->createMock(IBackend::class); $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $this->server->expects($this->at(0)) + ->method('query') + ->with('calendar_resource_backend1') + ->will($this->returnValue($backend1)); $backend2 = $this->createMock(IBackend::class); $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $this->server->expects($this->at(1)) + ->method('query') + ->with('calendar_resource_backend2') + ->will($this->returnValue($backend2)); - $this->manager->registerBackend($backend1); - $this->manager->registerBackend($backend2); + $this->manager->registerBackend('calendar_resource_backend1'); + $this->manager->registerBackend('calendar_resource_backend2'); $this->assertEquals([ $backend1, $backend2 ], $this->manager->getBackends()); - $this->manager->unregisterBackend($backend1); + $this->manager->unregisterBackend('calendar_resource_backend1'); $this->assertEquals([ $backend2 @@ -62,12 +75,20 @@ class ManagerTest extends TestCase { public function testGetBackend() { $backend1 = $this->createMock(IBackend::class); $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $this->server->expects($this->at(0)) + ->method('query') + ->with('calendar_resource_backend1') + ->will($this->returnValue($backend1)); $backend2 = $this->createMock(IBackend::class); $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $this->server->expects($this->at(1)) + ->method('query') + ->with('calendar_resource_backend2') + ->will($this->returnValue($backend2)); - $this->manager->registerBackend($backend1); - $this->manager->registerBackend($backend2); + $this->manager->registerBackend('calendar_resource_backend1'); + $this->manager->registerBackend('calendar_resource_backend2'); $this->assertEquals($backend1, $this->manager->getBackend('backend_1')); $this->assertEquals($backend2, $this->manager->getBackend('backend_2')); @@ -76,12 +97,20 @@ class ManagerTest extends TestCase { public function testClear() { $backend1 = $this->createMock(IBackend::class); $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $this->server->expects($this->at(0)) + ->method('query') + ->with('calendar_resource_backend1') + ->will($this->returnValue($backend1)); $backend2 = $this->createMock(IBackend::class); $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $this->server->expects($this->at(1)) + ->method('query') + ->with('calendar_resource_backend2') + ->will($this->returnValue($backend2)); - $this->manager->registerBackend($backend1); - $this->manager->registerBackend($backend2); + $this->manager->registerBackend('calendar_resource_backend1'); + $this->manager->registerBackend('calendar_resource_backend2'); $this->assertEquals([ $backend1, $backend2 diff --git a/tests/lib/Calendar/Room/ManagerTest.php b/tests/lib/Calendar/Room/ManagerTest.php index 34d69d127e2..52347f439fa 100644 --- a/tests/lib/Calendar/Room/ManagerTest.php +++ b/tests/lib/Calendar/Room/ManagerTest.php @@ -25,6 +25,7 @@ namespace Test\Calendar\Room; use \OC\Calendar\Room\Manager; use \OCP\Calendar\Room\IBackend; +use OCP\IServerContainer; use \Test\TestCase; class ManagerTest extends TestCase { @@ -32,27 +33,39 @@ class ManagerTest extends TestCase { /** @var Manager */ private $manager; + /** @var IServerContainer */ + private $server; + protected function setUp() { parent::setUp(); - $this->manager = new Manager(); + $this->server = $this->createMock(IServerContainer::class); + $this->manager = new Manager($this->server); } public function testRegisterUnregisterBackend() { $backend1 = $this->createMock(IBackend::class); $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $this->server->expects($this->at(0)) + ->method('query') + ->with('calendar_room_backend1') + ->will($this->returnValue($backend1)); $backend2 = $this->createMock(IBackend::class); $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $this->server->expects($this->at(1)) + ->method('query') + ->with('calendar_room_backend2') + ->will($this->returnValue($backend2)); - $this->manager->registerBackend($backend1); - $this->manager->registerBackend($backend2); + $this->manager->registerBackend('calendar_room_backend1'); + $this->manager->registerBackend('calendar_room_backend2'); $this->assertEquals([ $backend1, $backend2 ], $this->manager->getBackends()); - $this->manager->unregisterBackend($backend1); + $this->manager->unregisterBackend('calendar_room_backend1'); $this->assertEquals([ $backend2 @@ -62,12 +75,20 @@ class ManagerTest extends TestCase { public function testGetBackend() { $backend1 = $this->createMock(IBackend::class); $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $this->server->expects($this->at(0)) + ->method('query') + ->with('calendar_room_backend1') + ->will($this->returnValue($backend1)); $backend2 = $this->createMock(IBackend::class); $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $this->server->expects($this->at(1)) + ->method('query') + ->with('calendar_room_backend2') + ->will($this->returnValue($backend2)); - $this->manager->registerBackend($backend1); - $this->manager->registerBackend($backend2); + $this->manager->registerBackend('calendar_room_backend1'); + $this->manager->registerBackend('calendar_room_backend2'); $this->assertEquals($backend1, $this->manager->getBackend('backend_1')); $this->assertEquals($backend2, $this->manager->getBackend('backend_2')); @@ -76,12 +97,20 @@ class ManagerTest extends TestCase { public function testClear() { $backend1 = $this->createMock(IBackend::class); $backend1->method('getBackendIdentifier')->will($this->returnValue('backend_1')); + $this->server->expects($this->at(0)) + ->method('query') + ->with('calendar_room_backend1') + ->will($this->returnValue($backend1)); $backend2 = $this->createMock(IBackend::class); $backend2->method('getBackendIdentifier')->will($this->returnValue('backend_2')); + $this->server->expects($this->at(1)) + ->method('query') + ->with('calendar_room_backend2') + ->will($this->returnValue($backend2)); - $this->manager->registerBackend($backend1); - $this->manager->registerBackend($backend2); + $this->manager->registerBackend('calendar_room_backend1'); + $this->manager->registerBackend('calendar_room_backend2'); $this->assertEquals([ $backend1, $backend2 |