ApplicationTest.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\DAV\Tests\unit\AppInfo;
  24. use OCA\DAV\AppInfo\Application;
  25. use OCA\DAV\CardDAV\CardDavBackend;
  26. use OCA\DAV\CardDAV\ContactsManager;
  27. use OCP\Contacts\IManager;
  28. use Test\TestCase;
  29. /**
  30. * Class ApplicationTest
  31. *
  32. * @group DB
  33. *
  34. * @package OCA\DAV\Tests\Unit\AppInfo
  35. */
  36. class ApplicationTest extends TestCase {
  37. public function test() {
  38. $app = new Application();
  39. $c = $app->getContainer();
  40. // assert service instances in the container are properly setup
  41. $s = $c->query(ContactsManager::class);
  42. $this->assertInstanceOf('OCA\DAV\CardDAV\ContactsManager', $s);
  43. $s = $c->query(CardDavBackend::class);
  44. $this->assertInstanceOf('OCA\DAV\CardDAV\CardDavBackend', $s);
  45. }
  46. public function testContactsManagerSetup() {
  47. $app = new Application();
  48. $c = $app->getContainer();
  49. $c->registerService(CardDavBackend::class, function() {
  50. $service = $this->createMock(CardDavBackend::class);
  51. $service->method('getAddressBooksForUser')->willReturn([]);
  52. return $service;
  53. });
  54. // assert setupContactsProvider() is proper
  55. /** @var IManager|\PHPUnit_Framework_MockObject_MockObject $cm */
  56. $cm = $this->createMock(IManager::class);
  57. $app->setupContactsProvider($cm, 'xxx');
  58. $this->assertTrue(true);
  59. }
  60. }