server.php 6.2 KB

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