1
0

InfoXmlTest.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. namespace Test;
  22. use OCP\App\IAppManager;
  23. /**
  24. * Class InfoXmlTest
  25. *
  26. * @group DB
  27. * @package Test
  28. */
  29. class InfoXmlTest extends TestCase {
  30. public function dataApps() {
  31. return [
  32. ['admin_audit'],
  33. ['comments'],
  34. ['dav'],
  35. ['encryption'],
  36. ['federatedfilesharing'],
  37. ['federation'],
  38. ['files'],
  39. ['files_external'],
  40. ['files_sharing'],
  41. ['files_trashbin'],
  42. ['files_versions'],
  43. ['provisioning_api'],
  44. ['systemtags'],
  45. ['theming'],
  46. ['settings'],
  47. ['twofactor_backupcodes'],
  48. ['updatenotification'],
  49. ['user_ldap'],
  50. ['workflowengine'],
  51. ];
  52. }
  53. /**
  54. * @dataProvider dataApps
  55. *
  56. * @param string $app
  57. */
  58. public function testClasses($app) {
  59. $appInfo = \OCP\Server::get(IAppManager::class)->getAppInfo($app);
  60. $appPath = \OC_App::getAppPath($app);
  61. \OC_App::registerAutoloading($app, $appPath);
  62. //Add the appcontainer
  63. $applicationClassName = \OCP\AppFramework\App::buildAppNamespace($app) . '\\AppInfo\\Application';
  64. if (class_exists($applicationClassName)) {
  65. $application = new $applicationClassName();
  66. $this->addToAssertionCount(1);
  67. } else {
  68. $application = new \OCP\AppFramework\App($app);
  69. $this->addToAssertionCount(1);
  70. }
  71. if (isset($appInfo['background-jobs'])) {
  72. foreach ($appInfo['background-jobs'] as $job) {
  73. $this->assertTrue(class_exists($job), 'Asserting background job "' . $job . '" exists');
  74. $this->assertInstanceOf($job, \OC::$server->query($job));
  75. }
  76. }
  77. if (isset($appInfo['two-factor-providers'])) {
  78. foreach ($appInfo['two-factor-providers'] as $provider) {
  79. $this->assertTrue(class_exists($provider), 'Asserting two-factor providers "' . $provider . '" exists');
  80. $this->assertInstanceOf($provider, \OC::$server->query($provider));
  81. }
  82. }
  83. if (isset($appInfo['commands'])) {
  84. foreach ($appInfo['commands'] as $command) {
  85. $this->assertTrue(class_exists($command), 'Asserting command "' . $command . '" exists');
  86. $this->assertInstanceOf($command, \OC::$server->query($command));
  87. }
  88. }
  89. if (isset($appInfo['repair-steps']['pre-migration'])) {
  90. foreach ($appInfo['repair-steps']['pre-migration'] as $migration) {
  91. $this->assertTrue(class_exists($migration), 'Asserting pre-migration "' . $migration . '" exists');
  92. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  93. }
  94. }
  95. if (isset($appInfo['repair-steps']['post-migration'])) {
  96. foreach ($appInfo['repair-steps']['post-migration'] as $migration) {
  97. $this->assertTrue(class_exists($migration), 'Asserting post-migration "' . $migration . '" exists');
  98. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  99. }
  100. }
  101. if (isset($appInfo['repair-steps']['live-migration'])) {
  102. foreach ($appInfo['repair-steps']['live-migration'] as $migration) {
  103. $this->assertTrue(class_exists($migration), 'Asserting live-migration "' . $migration . '" exists');
  104. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  105. }
  106. }
  107. if (isset($appInfo['repair-steps']['install'])) {
  108. foreach ($appInfo['repair-steps']['install'] as $migration) {
  109. $this->assertTrue(class_exists($migration), 'Asserting install-migration "' . $migration . '" exists');
  110. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  111. }
  112. }
  113. if (isset($appInfo['repair-steps']['uninstall'])) {
  114. foreach ($appInfo['repair-steps']['uninstall'] as $migration) {
  115. $this->assertTrue(class_exists($migration), 'Asserting uninstall-migration "' . $migration . '" exists');
  116. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  117. }
  118. }
  119. if (isset($appInfo['commands'])) {
  120. foreach ($appInfo['commands'] as $command) {
  121. $this->assertTrue(class_exists($command), 'Asserting command "'. $command . '"exists');
  122. $this->assertInstanceOf($command, \OC::$server->query($command));
  123. }
  124. }
  125. }
  126. }