apps.php 979 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. foreach ($apps as $app) {
  37. $dir = OC_App::getAppPath($app);
  38. if (is_dir($dir . '/tests')) {
  39. loadDirectory($dir . '/tests');
  40. }
  41. }