1
0

InfoXmlTest.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. /**
  23. * Class InfoXmlTest
  24. *
  25. * @group DB
  26. * @package Test
  27. */
  28. class InfoXmlTest extends TestCase {
  29. public function dataApps() {
  30. return [
  31. ['admin_audit'],
  32. ['comments'],
  33. ['dav'],
  34. ['encryption'],
  35. ['federatedfilesharing'],
  36. ['federation'],
  37. ['files'],
  38. ['files_external'],
  39. ['files_sharing'],
  40. ['files_trashbin'],
  41. ['files_versions'],
  42. ['provisioning_api'],
  43. ['systemtags'],
  44. ['theming'],
  45. ['twofactor_backupcodes'],
  46. ['updatenotification'],
  47. ['user_ldap'],
  48. ['workflowengine'],
  49. ];
  50. }
  51. /**
  52. * @dataProvider dataApps
  53. *
  54. * @param string $app
  55. */
  56. public function testClasses($app) {
  57. $appInfo = \OC_App::getAppInfo($app);
  58. $appPath = \OC_App::getAppPath($app);
  59. \OC_App::registerAutoloading($app, $appPath);
  60. //Add the appcontainer
  61. $applicationClassName = \OCP\AppFramework\App::buildAppNamespace($app) . '\\AppInfo\\Application';
  62. if (class_exists($applicationClassName)) {
  63. $application = new $applicationClassName();
  64. } else {
  65. $application = new \OCP\AppFramework\App($app);
  66. }
  67. if (isset($appInfo['background-jobs'])) {
  68. foreach ($appInfo['background-jobs'] as $job) {
  69. $this->assertTrue(class_exists($job), 'Asserting background job "' . $job . '" exists');
  70. $this->assertInstanceOf($job, \OC::$server->query($job));
  71. }
  72. }
  73. if (isset($appInfo['two-factor-providers'])) {
  74. foreach ($appInfo['two-factor-providers'] as $provider) {
  75. $this->assertTrue(class_exists($provider), 'Asserting two-factor providers "' . $provider . '" exists');
  76. $this->assertInstanceOf($provider, \OC::$server->query($provider));
  77. }
  78. }
  79. if (isset($appInfo['commands'])) {
  80. foreach ($appInfo['commands'] as $command) {
  81. $this->assertTrue(class_exists($command), 'Asserting command "' . $command . '" exists');
  82. $this->assertInstanceOf($command, \OC::$server->query($command));
  83. }
  84. }
  85. if (isset($appInfo['repair-steps']['pre-migration'])) {
  86. foreach ($appInfo['repair-steps']['pre-migration'] as $migration) {
  87. $this->assertTrue(class_exists($migration), 'Asserting pre-migration "' . $migration . '" exists');
  88. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  89. }
  90. }
  91. if (isset($appInfo['repair-steps']['post-migration'])) {
  92. foreach ($appInfo['repair-steps']['post-migration'] as $migration) {
  93. $this->assertTrue(class_exists($migration), 'Asserting post-migration "' . $migration . '" exists');
  94. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  95. }
  96. }
  97. if (isset($appInfo['repair-steps']['live-migration'])) {
  98. foreach ($appInfo['repair-steps']['live-migration'] as $migration) {
  99. $this->assertTrue(class_exists($migration), 'Asserting live-migration "' . $migration . '" exists');
  100. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  101. }
  102. }
  103. if (isset($appInfo['repair-steps']['install'])) {
  104. foreach ($appInfo['repair-steps']['install'] as $migration) {
  105. $this->assertTrue(class_exists($migration), 'Asserting install-migration "' . $migration . '" exists');
  106. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  107. }
  108. }
  109. if (isset($appInfo['repair-steps']['uninstall'])) {
  110. foreach ($appInfo['repair-steps']['uninstall'] as $migration) {
  111. $this->assertTrue(class_exists($migration), 'Asserting uninstall-migration "' . $migration . '" exists');
  112. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  113. }
  114. }
  115. if (isset($appInfo['commands'])) {
  116. foreach ($appInfo['commands'] as $command) {
  117. $this->assertTrue(class_exists($command), 'Asserting command "'. $command . '"exists');
  118. $this->assertInstanceOf($command, \OC::$server->query($command));
  119. }
  120. }
  121. }
  122. }