From f8180391fd668ec8e4cb6366bf43682ced99509b Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Thu, 19 May 2016 15:45:34 +0200 Subject: [PATCH] Create a Fallback in the old autoloader for PSR-4 Test\TestCase --- lib/autoloader.php | 4 ++++ tests/lib/{testcase.php => TestCase.php} | 0 tests/lib/autoloader.php | 6 ++++++ 3 files changed, 10 insertions(+) rename tests/lib/{testcase.php => TestCase.php} (100%) diff --git a/lib/autoloader.php b/lib/autoloader.php index ff9db924cd..215da536e5 100644 --- a/lib/autoloader.php +++ b/lib/autoloader.php @@ -113,6 +113,10 @@ class Autoloader { // If not found in the root of the app directory, insert '/lib' after app id and try again. $paths[] = $appPath . '/lib/' . strtolower(str_replace('\\', '/', $rest) . '.php'); } + } elseif ($class === 'Test\\TestCase') { + // This File is considered public API, so we make sure that the class + // can still be loaded, although the PSR-4 paths have not been loaded. + $paths[] = \OC::$SERVERROOT . '/tests/lib/TestCase.php'; } elseif (strpos($class, 'Test\\') === 0) { $paths[] = \OC::$SERVERROOT . '/tests/lib/' . strtolower(str_replace('\\', '/', substr($class, 5)) . '.php'); } diff --git a/tests/lib/testcase.php b/tests/lib/TestCase.php similarity index 100% rename from tests/lib/testcase.php rename to tests/lib/TestCase.php diff --git a/tests/lib/autoloader.php b/tests/lib/autoloader.php index 5268ef424d..3669f514be 100644 --- a/tests/lib/autoloader.php +++ b/tests/lib/autoloader.php @@ -37,6 +37,12 @@ class AutoLoader extends TestCase { ], $this->loader->findClass('OC_Files')); } + public function testLoadTestTestCase() { + $this->assertEquals([ + \OC::$SERVERROOT . '/tests/lib/TestCase.php' + ], $this->loader->findClass('Test\TestCase')); + } + public function testLoadTestNamespace() { $this->assertEquals([ \OC::$SERVERROOT . '/tests/lib/foo/bar.php'