1
0

apps.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. function loadDirectory($path): void {
  8. if (strpos($path, 'apps/user_ldap/tests/Integration')) {
  9. return;
  10. }
  11. if (! $dh = opendir($path)) {
  12. return;
  13. }
  14. while (($name = readdir($dh)) !== false) {
  15. if ($name[0] === '.') {
  16. continue;
  17. }
  18. $file = $path . '/' . $name;
  19. if (is_dir($file)) {
  20. loadDirectory($file);
  21. } elseif (str_ends_with($name, '.php')) {
  22. require_once $file;
  23. }
  24. }
  25. }
  26. function getSubclasses($parentClassName): array {
  27. $classes = [];
  28. foreach (get_declared_classes() as $className) {
  29. if (is_subclass_of($className, $parentClassName)) {
  30. $classes[] = $className;
  31. }
  32. }
  33. return $classes;
  34. }
  35. $apps = OC_App::getEnabledApps();
  36. $appManager = \OCP\Server::get(\OCP\App\IAppManager::class);
  37. foreach ($apps as $app) {
  38. try {
  39. $dir = $appManager->getAppPath($app);
  40. if (is_dir($dir . '/tests')) {
  41. loadDirectory($dir . '/tests');
  42. }
  43. } catch (\OCP\App\AppPathNotFoundException) {
  44. /* ignore */
  45. }
  46. }