1
0

ServerTest.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. * @author Lukas Reschke <lukas@owncloud.com>
  5. * @author Roeland Jago Douma <roeland@famdouma.nl>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @copyright Copyright (c) 2015, ownCloud, Inc.
  9. * @license AGPL-3.0
  10. *
  11. * This code is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License, version 3,
  13. * as published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU Affero General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Affero General Public License, version 3,
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>
  22. *
  23. */
  24. namespace Test;
  25. use OC\App\AppStore\Fetcher\AppFetcher;
  26. use OC\App\AppStore\Fetcher\CategoryFetcher;
  27. /**
  28. * Class Server
  29. *
  30. * @group DB
  31. *
  32. * @package Test
  33. */
  34. class ServerTest extends \Test\TestCase {
  35. /** @var \OC\Server */
  36. protected $server;
  37. public function setUp() {
  38. parent::setUp();
  39. $config = new \OC\Config(\OC::$configDir);
  40. $this->server = new \OC\Server('', $config);
  41. }
  42. public function dataTestQuery() {
  43. return [
  44. ['ActivityManager', '\OC\Activity\Manager'],
  45. ['ActivityManager', '\OCP\Activity\IManager'],
  46. ['AllConfig', '\OC\AllConfig'],
  47. ['AllConfig', '\OCP\IConfig'],
  48. ['AppConfig', '\OC\AppConfig'],
  49. ['AppConfig', '\OCP\IAppConfig'],
  50. ['AppFetcher', AppFetcher::class],
  51. ['AppHelper', '\OC\AppHelper'],
  52. ['AppHelper', '\OCP\IHelper'],
  53. ['AppManager', '\OC\App\AppManager'],
  54. ['AppManager', '\OCP\App\IAppManager'],
  55. ['AsyncCommandBus', '\OC\Command\AsyncBus'],
  56. ['AsyncCommandBus', '\OCP\Command\IBus'],
  57. ['AvatarManager', '\OC\AvatarManager'],
  58. ['AvatarManager', '\OCP\IAvatarManager'],
  59. ['CategoryFetcher', CategoryFetcher::class],
  60. ['CapabilitiesManager', '\OC\CapabilitiesManager'],
  61. ['ContactsManager', '\OC\ContactsManager'],
  62. ['ContactsManager', '\OCP\Contacts\IManager'],
  63. ['ContentSecurityPolicyManager', '\OC\Security\CSP\ContentSecurityPolicyManager'],
  64. ['CommentsManager', '\OCP\Comments\ICommentsManager'],
  65. ['Crypto', '\OC\Security\Crypto'],
  66. ['Crypto', '\OCP\Security\ICrypto'],
  67. ['CryptoWrapper', '\OC\Session\CryptoWrapper'],
  68. ['CsrfTokenManager', '\OC\Security\CSRF\CsrfTokenManager'],
  69. ['DatabaseConnection', '\OC\DB\Connection'],
  70. ['DatabaseConnection', '\OCP\IDBConnection'],
  71. ['DateTimeFormatter', '\OC\DateTimeFormatter'],
  72. ['DateTimeFormatter', '\OCP\IDateTimeFormatter'],
  73. ['DateTimeZone', '\OC\DateTimeZone'],
  74. ['DateTimeZone', '\OCP\IDateTimeZone'],
  75. ['EncryptionFileHelper', '\OC\Encryption\File'],
  76. ['EncryptionFileHelper', '\OCP\Encryption\IFile'],
  77. ['EncryptionKeyStorage', '\OC\Encryption\Keys\Storage'],
  78. ['EncryptionKeyStorage', '\OCP\Encryption\Keys\IStorage'],
  79. ['EncryptionManager', '\OC\Encryption\Manager'],
  80. ['EncryptionManager', '\OCP\Encryption\IManager'],
  81. ['EventLogger', '\OCP\Diagnostics\IEventLogger'],
  82. ['GroupManager', '\OC\Group\Manager'],
  83. ['GroupManager', '\OCP\IGroupManager'],
  84. ['Hasher', '\OC\Security\Hasher'],
  85. ['Hasher', '\OCP\Security\IHasher'],
  86. ['HTTPHelper', '\OC\HTTPHelper'],
  87. ['HttpClientService', '\OC\Http\Client\ClientService'],
  88. ['HttpClientService', '\OCP\Http\Client\IClientService'],
  89. ['IniWrapper', '\bantu\IniGetWrapper\IniGetWrapper'],
  90. ['MimeTypeDetector', '\OCP\Files\IMimeTypeDetector'],
  91. ['MimeTypeDetector', '\OC\Files\Type\Detection'],
  92. ['JobList', '\OC\BackgroundJob\JobList'],
  93. ['JobList', '\OCP\BackgroundJob\IJobList'],
  94. ['L10NFactory', '\OC\L10N\Factory'],
  95. ['L10NFactory', '\OCP\L10N\IFactory'],
  96. ['LockingProvider', '\OCP\Lock\ILockingProvider'],
  97. ['Logger', '\OC\Log'],
  98. ['Logger', '\OCP\ILogger'],
  99. ['Mailer', '\OC\Mail\Mailer'],
  100. ['Mailer', '\OCP\Mail\IMailer'],
  101. ['MemCacheFactory', '\OC\Memcache\Factory'],
  102. ['MemCacheFactory', '\OCP\ICacheFactory'],
  103. ['MountConfigManager', '\OC\Files\Config\MountProviderCollection'],
  104. ['MountConfigManager', '\OCP\Files\Config\IMountProviderCollection'],
  105. ['NavigationManager', '\OC\NavigationManager'],
  106. ['NavigationManager', '\OCP\INavigationManager'],
  107. ['NotificationManager', '\OC\Notification\Manager'],
  108. ['NotificationManager', '\OCP\Notification\IManager'],
  109. ['UserCache', '\OC\Cache\File'],
  110. ['UserCache', '\OCP\ICache'],
  111. ['PreviewManager', '\OC\PreviewManager'],
  112. ['PreviewManager', '\OCP\IPreview'],
  113. ['QueryLogger', '\OCP\Diagnostics\IQueryLogger'],
  114. ['Request', '\OC\AppFramework\Http\Request'],
  115. ['Request', '\OCP\IRequest'],
  116. ['RootFolder', '\OC\Files\Node\Root'],
  117. ['RootFolder', '\OC\Files\Node\Folder'],
  118. ['RootFolder', '\OCP\Files\IRootFolder'],
  119. ['RootFolder', '\OCP\Files\Folder'],
  120. ['Router', '\OCP\Route\IRouter'],
  121. ['Search', '\OC\Search'],
  122. ['Search', '\OCP\ISearch'],
  123. ['SecureRandom', '\OC\Security\SecureRandom'],
  124. ['SecureRandom', '\OCP\Security\ISecureRandom'],
  125. ['ShareManager', '\OC\Share20\Manager'],
  126. ['ShareManager', '\OCP\Share\IManager'],
  127. ['SystemConfig', '\OC\SystemConfig'],
  128. ['URLGenerator', '\OC\URLGenerator'],
  129. ['URLGenerator', '\OCP\IURLGenerator'],
  130. ['UserManager', '\OC\User\Manager'],
  131. ['UserManager', '\OCP\IUserManager'],
  132. ['UserSession', '\OC\User\Session'],
  133. ['UserSession', '\OCP\IUserSession'],
  134. ['TagMapper', '\OC\Tagging\TagMapper'],
  135. ['TagMapper', '\OCP\AppFramework\Db\Mapper'],
  136. ['TagManager', '\OC\TagManager'],
  137. ['TagManager', '\OCP\ITagManager'],
  138. ['TempManager', '\OC\TempManager'],
  139. ['TempManager', '\OCP\ITempManager'],
  140. ['ThemingDefaults', '\OCA\Theming\ThemingDefaults'],
  141. ['TrustedDomainHelper', '\OC\Security\TrustedDomainHelper'],
  142. ['SystemTagManager', '\OCP\SystemTag\ISystemTagManager'],
  143. ['SystemTagObjectMapper', '\OCP\SystemTag\ISystemTagObjectMapper'],
  144. ];
  145. }
  146. /**
  147. * @dataProvider dataTestQuery
  148. *
  149. * @param string $serviceName
  150. * @param string $instanceOf
  151. */
  152. public function testQuery($serviceName, $instanceOf) {
  153. $this->assertInstanceOf($instanceOf, $this->server->query($serviceName), 'Service "' . $serviceName . '"" did not return the right class');
  154. }
  155. public function testGetCertificateManager() {
  156. $this->assertInstanceOf('\OC\Security\CertificateManager', $this->server->getCertificateManager('test'), 'service returned by "getCertificateManager" did not return the right class');
  157. $this->assertInstanceOf('\OCP\ICertificateManager', $this->server->getCertificateManager('test'), 'service returned by "getCertificateManager" did not return the right class');
  158. }
  159. public function testCreateEventSource() {
  160. $this->assertInstanceOf('\OC_EventSource', $this->server->createEventSource(), 'service returned by "createEventSource" did not return the right class');
  161. $this->assertInstanceOf('\OCP\IEventSource', $this->server->createEventSource(), 'service returned by "createEventSource" did not return the right class');
  162. }
  163. public function testOverwriteDefaultCommentsManager() {
  164. $config = $this->server->getConfig();
  165. $defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
  166. $config->setSystemValue('comments.managerFactory', '\Test\Comments\FakeFactory');
  167. $manager = $this->server->getCommentsManager();
  168. $this->assertInstanceOf('\OCP\Comments\ICommentsManager', $manager);
  169. $config->setSystemValue('comments.managerFactory', $defaultManagerFactory);
  170. }
  171. }