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.

server.php 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. /**
  26. * Class Server
  27. *
  28. * @group DB
  29. *
  30. * @package Test
  31. */
  32. class Server extends \Test\TestCase {
  33. /** @var \OC\Server */
  34. protected $server;
  35. public function setUp() {
  36. parent::setUp();
  37. $config = new \OC\Config(\OC::$configDir);
  38. $this->server = new \OC\Server('', $config);
  39. }
  40. public function dataTestQuery() {
  41. return [
  42. ['ActivityManager', '\OC\ActivityManager'],
  43. ['ActivityManager', '\OCP\Activity\IManager'],
  44. ['AllConfig', '\OC\AllConfig'],
  45. ['AllConfig', '\OCP\IConfig'],
  46. ['AppConfig', '\OC\AppConfig'],
  47. ['AppConfig', '\OCP\IAppConfig'],
  48. ['AppHelper', '\OC\AppHelper'],
  49. ['AppHelper', '\OCP\IHelper'],
  50. ['AppManager', '\OC\App\AppManager'],
  51. ['AppManager', '\OCP\App\IAppManager'],
  52. ['AsyncCommandBus', '\OC\Command\AsyncBus'],
  53. ['AsyncCommandBus', '\OCP\Command\IBus'],
  54. ['AvatarManager', '\OC\AvatarManager'],
  55. ['AvatarManager', '\OCP\IAvatarManager'],
  56. ['CapabilitiesManager', '\OC\CapabilitiesManager'],
  57. ['ContactsManager', '\OC\ContactsManager'],
  58. ['ContactsManager', '\OCP\Contacts\IManager'],
  59. ['CommentsManager', '\OCP\Comments\ICommentsManager'],
  60. ['Crypto', '\OC\Security\Crypto'],
  61. ['Crypto', '\OCP\Security\ICrypto'],
  62. ['CryptoWrapper', '\OC\Session\CryptoWrapper'],
  63. ['DatabaseConnection', '\OC\DB\Connection'],
  64. ['DatabaseConnection', '\OCP\IDBConnection'],
  65. ['DateTimeFormatter', '\OC\DateTimeFormatter'],
  66. ['DateTimeFormatter', '\OCP\IDateTimeFormatter'],
  67. ['DateTimeZone', '\OC\DateTimeZone'],
  68. ['DateTimeZone', '\OCP\IDateTimeZone'],
  69. ['Db', '\OC\AppFramework\Db\Db'],
  70. ['Db', '\OCP\IDb'],
  71. ['EncryptionFileHelper', '\OC\Encryption\File'],
  72. ['EncryptionFileHelper', '\OCP\Encryption\IFile'],
  73. ['EncryptionKeyStorage', '\OC\Encryption\Keys\Storage'],
  74. ['EncryptionKeyStorage', '\OCP\Encryption\Keys\IStorage'],
  75. ['EncryptionManager', '\OC\Encryption\Manager'],
  76. ['EncryptionManager', '\OCP\Encryption\IManager'],
  77. ['EventLogger', '\OCP\Diagnostics\IEventLogger'],
  78. ['GroupManager', '\OC\Group\Manager'],
  79. ['GroupManager', '\OCP\IGroupManager'],
  80. ['Hasher', '\OC\Security\Hasher'],
  81. ['Hasher', '\OCP\Security\IHasher'],
  82. ['HTTPHelper', '\OC\HTTPHelper'],
  83. ['HttpClientService', '\OC\Http\Client\ClientService'],
  84. ['HttpClientService', '\OCP\Http\Client\IClientService'],
  85. ['IniWrapper', '\bantu\IniGetWrapper\IniGetWrapper'],
  86. ['MimeTypeDetector', '\OCP\Files\IMimeTypeDetector'],
  87. ['MimeTypeDetector', '\OC\Files\Type\Detection'],
  88. ['JobList', '\OC\BackgroundJob\JobList'],
  89. ['JobList', '\OCP\BackgroundJob\IJobList'],
  90. ['L10NFactory', '\OC\L10N\Factory'],
  91. ['L10NFactory', '\OCP\L10N\IFactory'],
  92. ['LockingProvider', '\OCP\Lock\ILockingProvider'],
  93. ['Logger', '\OC\Log'],
  94. ['Logger', '\OCP\ILogger'],
  95. ['Mailer', '\OC\Mail\Mailer'],
  96. ['Mailer', '\OCP\Mail\IMailer'],
  97. ['MemCacheFactory', '\OC\Memcache\Factory'],
  98. ['MemCacheFactory', '\OCP\ICacheFactory'],
  99. ['MountConfigManager', '\OC\Files\Config\MountProviderCollection'],
  100. ['MountConfigManager', '\OCP\Files\Config\IMountProviderCollection'],
  101. ['NavigationManager', '\OC\NavigationManager'],
  102. ['NavigationManager', '\OCP\INavigationManager'],
  103. ['NotificationManager', '\OC\Notification\Manager'],
  104. ['NotificationManager', '\OC\Notification\IManager'],
  105. ['UserCache', '\OC\Cache\File'],
  106. ['UserCache', '\OCP\ICache'],
  107. ['OcsClient', '\OC\OCSClient'],
  108. ['PreviewManager', '\OC\PreviewManager'],
  109. ['PreviewManager', '\OCP\IPreview'],
  110. ['QueryLogger', '\OCP\Diagnostics\IQueryLogger'],
  111. ['Request', '\OC\AppFramework\Http\Request'],
  112. ['Request', '\OCP\IRequest'],
  113. ['RootFolder', '\OC\Files\Node\Root'],
  114. ['RootFolder', '\OC\Files\Node\Folder'],
  115. ['RootFolder', '\OCP\Files\IRootFolder'],
  116. ['RootFolder', '\OCP\Files\Folder'],
  117. ['Router', '\OCP\Route\IRouter'],
  118. ['Search', '\OC\Search'],
  119. ['Search', '\OCP\ISearch'],
  120. ['SecureRandom', '\OC\Security\SecureRandom'],
  121. ['SecureRandom', '\OCP\Security\ISecureRandom'],
  122. ['SystemConfig', '\OC\SystemConfig'],
  123. ['URLGenerator', '\OC\URLGenerator'],
  124. ['URLGenerator', '\OCP\IURLGenerator'],
  125. ['UserManager', '\OC\User\Manager'],
  126. ['UserManager', '\OCP\IUserManager'],
  127. ['UserSession', '\OC\User\Session'],
  128. ['UserSession', '\OCP\IUserSession'],
  129. ['TagMapper', '\OC\Tagging\TagMapper'],
  130. ['TagMapper', '\OCP\AppFramework\Db\Mapper'],
  131. ['TagManager', '\OC\TagManager'],
  132. ['TagManager', '\OCP\ITagManager'],
  133. ['TempManager', '\OC\TempManager'],
  134. ['TempManager', '\OCP\ITempManager'],
  135. ['TrustedDomainHelper', '\OC\Security\TrustedDomainHelper'],
  136. ];
  137. }
  138. /**
  139. * @dataProvider dataTestQuery
  140. *
  141. * @param string $serviceName
  142. * @param string $instanceOf
  143. */
  144. public function testQuery($serviceName, $instanceOf) {
  145. $this->assertInstanceOf($instanceOf, $this->server->query($serviceName), 'Service "' . $serviceName . '"" did not return the right class');
  146. }
  147. public function testGetCertificateManager() {
  148. $this->assertInstanceOf('\OC\Security\CertificateManager', $this->server->getCertificateManager('test'), 'service returned by "getCertificateManager" did not return the right class');
  149. $this->assertInstanceOf('\OCP\ICertificateManager', $this->server->getCertificateManager('test'), 'service returned by "getCertificateManager" did not return the right class');
  150. }
  151. public function testCreateEventSource() {
  152. $this->assertInstanceOf('\OC_EventSource', $this->server->createEventSource(), 'service returned by "createEventSource" did not return the right class');
  153. $this->assertInstanceOf('\OCP\IEventSource', $this->server->createEventSource(), 'service returned by "createEventSource" did not return the right class');
  154. }
  155. public function testOverwriteDefaultCommentsManager() {
  156. $config = $this->server->getConfig();
  157. $defaultManagerFactory = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
  158. $config->setSystemValue('comments.managerFactory', '\Test\Comments\FakeFactory');
  159. $manager = $this->server->getCommentsManager();
  160. $this->assertInstanceOf('\OCP\Comments\ICommentsManager', $manager);
  161. $config->setSystemValue('comments.managerFactory', $defaultManagerFactory);
  162. }
  163. }