InfoXmlTest.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace Test;
  7. use OCP\App\IAppManager;
  8. /**
  9. * Class InfoXmlTest
  10. *
  11. * @group DB
  12. * @package Test
  13. */
  14. class InfoXmlTest extends TestCase {
  15. public function dataApps() {
  16. return [
  17. ['admin_audit'],
  18. ['comments'],
  19. ['dav'],
  20. ['encryption'],
  21. ['federatedfilesharing'],
  22. ['federation'],
  23. ['files'],
  24. ['files_external'],
  25. ['files_sharing'],
  26. ['files_trashbin'],
  27. ['files_versions'],
  28. ['provisioning_api'],
  29. ['systemtags'],
  30. ['theming'],
  31. ['settings'],
  32. ['twofactor_backupcodes'],
  33. ['updatenotification'],
  34. ['user_ldap'],
  35. ['workflowengine'],
  36. ];
  37. }
  38. /**
  39. * @dataProvider dataApps
  40. *
  41. * @param string $app
  42. */
  43. public function testClasses($app) {
  44. $appInfo = \OCP\Server::get(IAppManager::class)->getAppInfo($app);
  45. $appPath = \OC_App::getAppPath($app);
  46. \OC_App::registerAutoloading($app, $appPath);
  47. //Add the appcontainer
  48. $applicationClassName = \OCP\AppFramework\App::buildAppNamespace($app) . '\\AppInfo\\Application';
  49. if (class_exists($applicationClassName)) {
  50. $application = new $applicationClassName();
  51. $this->addToAssertionCount(1);
  52. } else {
  53. $application = new \OCP\AppFramework\App($app);
  54. $this->addToAssertionCount(1);
  55. }
  56. if (isset($appInfo['background-jobs'])) {
  57. foreach ($appInfo['background-jobs'] as $job) {
  58. $this->assertTrue(class_exists($job), 'Asserting background job "' . $job . '" exists');
  59. $this->assertInstanceOf($job, \OC::$server->query($job));
  60. }
  61. }
  62. if (isset($appInfo['two-factor-providers'])) {
  63. foreach ($appInfo['two-factor-providers'] as $provider) {
  64. $this->assertTrue(class_exists($provider), 'Asserting two-factor providers "' . $provider . '" exists');
  65. $this->assertInstanceOf($provider, \OC::$server->query($provider));
  66. }
  67. }
  68. if (isset($appInfo['commands'])) {
  69. foreach ($appInfo['commands'] as $command) {
  70. $this->assertTrue(class_exists($command), 'Asserting command "' . $command . '" exists');
  71. $this->assertInstanceOf($command, \OC::$server->query($command));
  72. }
  73. }
  74. if (isset($appInfo['repair-steps']['pre-migration'])) {
  75. foreach ($appInfo['repair-steps']['pre-migration'] as $migration) {
  76. $this->assertTrue(class_exists($migration), 'Asserting pre-migration "' . $migration . '" exists');
  77. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  78. }
  79. }
  80. if (isset($appInfo['repair-steps']['post-migration'])) {
  81. foreach ($appInfo['repair-steps']['post-migration'] as $migration) {
  82. $this->assertTrue(class_exists($migration), 'Asserting post-migration "' . $migration . '" exists');
  83. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  84. }
  85. }
  86. if (isset($appInfo['repair-steps']['live-migration'])) {
  87. foreach ($appInfo['repair-steps']['live-migration'] as $migration) {
  88. $this->assertTrue(class_exists($migration), 'Asserting live-migration "' . $migration . '" exists');
  89. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  90. }
  91. }
  92. if (isset($appInfo['repair-steps']['install'])) {
  93. foreach ($appInfo['repair-steps']['install'] as $migration) {
  94. $this->assertTrue(class_exists($migration), 'Asserting install-migration "' . $migration . '" exists');
  95. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  96. }
  97. }
  98. if (isset($appInfo['repair-steps']['uninstall'])) {
  99. foreach ($appInfo['repair-steps']['uninstall'] as $migration) {
  100. $this->assertTrue(class_exists($migration), 'Asserting uninstall-migration "' . $migration . '" exists');
  101. $this->assertInstanceOf($migration, \OC::$server->query($migration));
  102. }
  103. }
  104. if (isset($appInfo['commands'])) {
  105. foreach ($appInfo['commands'] as $command) {
  106. $this->assertTrue(class_exists($command), 'Asserting command "'. $command . '"exists');
  107. $this->assertInstanceOf($command, \OC::$server->query($command));
  108. }
  109. }
  110. }
  111. }