diff options
author | Tobia De Koninck <tobia@ledfan.be> | 2017-10-01 16:53:44 +0300 |
---|---|---|
committer | Tobia De Koninck <tobia@ledfan.be> | 2018-02-08 16:19:49 +0300 |
commit | 16bf40c5c0fa8fae553c16664c1d67202b7db315 (patch) | |
tree | 41bd7e72db1f36d0a37097fa32c2688710b1b7e2 | |
parent | a49fb2c0777c877f1c92c07c5d01831439abe432 (diff) |
Move Checking for ContactsStore API to seperate function
Signed-off-by: Tobia De Koninck <tobia@ledfan.be>
-rw-r--r-- | appinfo/application.php | 13 | ||||
-rw-r--r-- | tests/integration/db/PresenceMapperTest.php | 52 |
2 files changed, 39 insertions, 26 deletions
diff --git a/appinfo/application.php b/appinfo/application.php index fb55c25..a8840eb 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -243,8 +243,7 @@ class Application extends App { }); $container->registerService('UserProvider', function(IContainer $c) { - $version = \OCP\Util::getVersion(); - if ($version[0] === 13) { + if (self::contactsStoreApiSupporetd()) { return new ContactsStoreUserProvider( $c->query('OCP\Contacts\ContactsMenu\IContactsStore'), $c->query('ServerContainer')->getUserSession(), @@ -342,4 +341,14 @@ class Application extends App { ) ); } + + /** + * @brief whether the ContactsStore API is enabled + * @return bool + */ + public static function contactsStoreApiSupporetd() { + $version = \OCP\Util::getVersion(); + return $version[0] === 13; + } + } diff --git a/tests/integration/db/PresenceMapperTest.php b/tests/integration/db/PresenceMapperTest.php index c4e322f..955bd34 100644 --- a/tests/integration/db/PresenceMapperTest.php +++ b/tests/integration/db/PresenceMapperTest.php @@ -2,6 +2,7 @@ namespace OCA\OJSXC\Db; +use OCA\OJSXC\AppInfo\Application; use OCA\OJSXC\Db\Presence as PresenceEntity; use OCA\OJSXC\NewContentContainer; use OCA\OJSXC\Utility\MapperTestUtility; @@ -56,34 +57,37 @@ class PresenceMapperTest extends MapperTestUtility public function setupContactsStoreAPI() { - foreach (\OC::$server->getUserManager()->search('') as $user) { - $user->delete(); - } + if (Application::contactsStoreApiSupporetd()) { - $users[] = \OC::$server->getUserManager()->createUser('admin', 'admin'); - $users[] = \OC::$server->getUserManager()->createUser('derp', 'derp'); - $users[] = \OC::$server->getUserManager()->createUser('derpina', 'derpina'); - $users[] = \OC::$server->getUserManager()->createUser('herp', 'herp'); - $users[] = \OC::$server->getUserManager()->createUser('foo', 'foo'); - - $currentUser = \OC::$server->getUserManager()->createUser('autotest', 'autotest'); - \OC::$server->getUserSession()->setUser($currentUser); - /** @var \OCA\DAV\CardDAV\SyncService $syncService */ - $syncService = \OC::$server->query('CardDAVSyncService'); - $syncService->getLocalSystemAddressBook(); - $syncService->updateUser($currentUser); - - foreach ($users as $user) { - $syncService->updateUser($user); - } + foreach (\OC::$server->getUserManager()->search('') as $user) { + $user->delete(); + } - $cm = \OC::$server->getContactsManager(); - $davApp = new DavApp(); - $davApp->setupSystemContactsProvider($cm); + $users[] = \OC::$server->getUserManager()->createUser('admin', 'admin'); + $users[] = \OC::$server->getUserManager()->createUser('derp', 'derp'); + $users[] = \OC::$server->getUserManager()->createUser('derpina', 'derpina'); + $users[] = \OC::$server->getUserManager()->createUser('herp', 'herp'); + $users[] = \OC::$server->getUserManager()->createUser('foo', 'foo'); - \OC_User::setIncognitoMode(false); + $currentUser = \OC::$server->getUserManager()->createUser('autotest', 'autotest'); + \OC::$server->getUserSession()->setUser($currentUser); + /** @var \OCA\DAV\CardDAV\SyncService $syncService */ + $syncService = \OC::$server->query('CardDAVSyncService'); + $syncService->getLocalSystemAddressBook(); + $syncService->updateUser($currentUser); - \OC::$server->getDatabaseConnection()->executeQuery("DELETE FROM *PREFIX*ojsxc_stanzas"); + foreach ($users as $user) { + $syncService->updateUser($user); + } + + $cm = \OC::$server->getContactsManager(); + $davApp = new DavApp(); + $davApp->setupSystemContactsProvider($cm); + + \OC_User::setIncognitoMode(false); + + \OC::$server->getDatabaseConnection()->executeQuery("DELETE FROM *PREFIX*ojsxc_stanzas"); + } } /** |