InfoXmlTest.php 4.1 KB

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