AutoLoaderTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Thomas Müller <thomas.mueller@tmit.eu>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test;
  9. class AutoLoaderTest extends TestCase {
  10. /**
  11. * @var \OC\Autoloader $loader
  12. */
  13. private $loader;
  14. protected function setUp(): void {
  15. parent::setUp();
  16. $this->loader = new \OC\AutoLoader([]);
  17. }
  18. public function testLegacyPath() {
  19. $this->assertEquals([
  20. \OC::$SERVERROOT . '/lib/private/legacy/files.php',
  21. ], $this->loader->findClass('OC_Files'));
  22. }
  23. public function testLoadTestTestCase() {
  24. $this->assertEquals([
  25. \OC::$SERVERROOT . '/tests/lib/TestCase.php'
  26. ], $this->loader->findClass('Test\TestCase'));
  27. }
  28. public function testLoadCore() {
  29. $this->assertEquals([
  30. \OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php',
  31. ], $this->loader->findClass('OC_Foo_Bar'));
  32. }
  33. public function testLoadPublicNamespace() {
  34. $this->assertEquals([], $this->loader->findClass('OCP\Foo\Bar'));
  35. }
  36. public function testLoadAppNamespace() {
  37. $result = $this->loader->findClass('OCA\Files\Foobar');
  38. $this->assertEquals(2, count($result));
  39. $this->assertStringEndsWith('apps/files/foobar.php', $result[0]);
  40. $this->assertStringEndsWith('apps/files/lib/foobar.php', $result[1]);
  41. }
  42. public function testLoadCoreNamespaceCore() {
  43. $this->assertEquals([], $this->loader->findClass('OC\Core\Foo\Bar'));
  44. }
  45. public function testLoadCoreNamespaceSettings() {
  46. $this->assertEquals([], $this->loader->findClass('OC\Settings\Foo\Bar'));
  47. }
  48. }