1
0

AutoLoaderTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace Test;
  8. class AutoLoaderTest extends TestCase {
  9. /**
  10. * @var \OC\Autoloader $loader
  11. */
  12. private $loader;
  13. protected function setUp(): void {
  14. parent::setUp();
  15. $this->loader = new \OC\AutoLoader([]);
  16. }
  17. public function testLegacyPath(): void {
  18. $this->assertEquals([
  19. \OC::$SERVERROOT . '/lib/private/legacy/json.php',
  20. ], $this->loader->findClass('OC_JSON'));
  21. }
  22. public function testLoadTestTestCase(): void {
  23. $this->assertEquals([
  24. \OC::$SERVERROOT . '/tests/lib/TestCase.php'
  25. ], $this->loader->findClass('Test\TestCase'));
  26. }
  27. public function testLoadCore(): void {
  28. $this->assertEquals([
  29. \OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php',
  30. ], $this->loader->findClass('OC_Foo_Bar'));
  31. }
  32. public function testLoadPublicNamespace(): void {
  33. $this->assertEquals([], $this->loader->findClass('OCP\Foo\Bar'));
  34. }
  35. public function testLoadAppNamespace(): void {
  36. $result = $this->loader->findClass('OCA\Files\Foobar');
  37. $this->assertEquals(2, count($result));
  38. $this->assertStringEndsWith('apps/files/foobar.php', $result[0]);
  39. $this->assertStringEndsWith('apps/files/lib/foobar.php', $result[1]);
  40. }
  41. public function testLoadCoreNamespaceCore(): void {
  42. $this->assertEquals([], $this->loader->findClass('OC\Core\Foo\Bar'));
  43. }
  44. public function testLoadCoreNamespaceSettings(): void {
  45. $this->assertEquals([], $this->loader->findClass('OC\Settings\Foo\Bar'));
  46. }
  47. }