Merge pull request #24728 from owncloud/no-more-test_-files
Fix autoloader for Test* files
This commit is contained in:
commit
b495895017
|
@ -94,7 +94,7 @@ class Autoloader {
|
|||
$paths[] = \OC::$CLASSPATH[$class];
|
||||
/**
|
||||
* @TODO: Remove this when necessary
|
||||
* Remove "apps/" from inclusion path for smooth migration to mutli app dir
|
||||
* Remove "apps/" from inclusion path for smooth migration to multi app dir
|
||||
*/
|
||||
if (strpos(\OC::$CLASSPATH[$class], 'apps/') === 0) {
|
||||
\OCP\Util::writeLog('core', 'include path for class "' . $class . '" starts with "apps/"', \OCP\Util::DEBUG);
|
||||
|
@ -113,8 +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 (strpos($class, 'Test_') === 0) {
|
||||
$paths[] = \OC::$SERVERROOT . '/tests/lib/' . strtolower(str_replace('_', '/', substr($class, 5)) . '.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');
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ if ($configDir) {
|
|||
|
||||
require_once __DIR__ . '/../lib/base.php';
|
||||
|
||||
\OC::$composerAutoloader->addPsr4('Test\\', OC::$SERVERROOT . '/tests/lib/', true);
|
||||
\OC::$composerAutoloader->addPsr4('Tests\\', OC::$SERVERROOT . '/tests/', true);
|
||||
\OC::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
|
||||
|
||||
// load all enabled apps
|
||||
|
|
|
@ -37,18 +37,18 @@ 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'
|
||||
], $this->loader->findClass('Test\Foo\Bar'));
|
||||
}
|
||||
|
||||
public function testLoadTest() {
|
||||
$this->assertEquals([
|
||||
\OC::$SERVERROOT . '/tests/lib/foo/bar.php'
|
||||
], $this->loader->findClass('Test_Foo_Bar'));
|
||||
}
|
||||
|
||||
public function testLoadCore() {
|
||||
$this->assertEquals([
|
||||
\OC::$SERVERROOT . '/lib/private/legacy/foo/bar.php',
|
||||
|
|
Loading…
Reference in New Issue