You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ApplicationTest.php 2.0KB

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