Browse Source
Create a Fallback in the old autoloader for PSR-4 Test\TestCase
remotes/origin/throw-loginexception-failed-login
Joas Schilling
10 years ago
No known key found for this signature in database
GPG Key ID: 70A0B324C41C0946
3 changed files with
10 additions and
0 deletions
-
lib/autoloader.php
-
tests/lib/TestCase.php
-
tests/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'); |
|
|
|
} |
|
|
|
|
|
|
|
@ -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' |
|
|
|
|