summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2016-05-20 09:29:01 +0200
committerVincent Petry <pvince81@owncloud.com>2016-05-20 09:29:01 +0200
commitb4958950178901ffd5b1d466f67b64558a8e5298 (patch)
tree2c0aed2840c9f41c884ca8d5375c677be4e8e96a
parent67162e636e44957f17c5456807239ca6b4a988db (diff)
parent54250ed06554cb59683f5c03a1e4529660febc52 (diff)
downloadnextcloud-server-b4958950178901ffd5b1d466f67b64558a8e5298.tar.gz
nextcloud-server-b4958950178901ffd5b1d466f67b64558a8e5298.zip
Merge pull request #24728 from owncloud/no-more-test_-files
Fix autoloader for Test* files
-rw-r--r--lib/autoloader.php8
-rw-r--r--tests/bootstrap.php2
-rw-r--r--tests/lib/TestCase.php (renamed from tests/lib/testcase.php)0
-rw-r--r--tests/lib/autoloader.php10
4 files changed, 12 insertions, 8 deletions
diff --git a/lib/autoloader.php b/lib/autoloader.php
index 9cc573c0997..215da536e5b 100644
--- a/lib/autoloader.php
+++ b/lib/autoloader.php
@@ -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');
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 86bedc3f325..e2b980b1c80 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.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
diff --git a/tests/lib/testcase.php b/tests/lib/TestCase.php
index 7ed121d3556..7ed121d3556 100644
--- a/tests/lib/testcase.php
+++ b/tests/lib/TestCase.php
diff --git a/tests/lib/autoloader.php b/tests/lib/autoloader.php
index adea702eca9..3669f514bee 100644
--- a/tests/lib/autoloader.php
+++ b/tests/lib/autoloader.php
@@ -37,16 +37,16 @@ class AutoLoader extends TestCase {
], $this->loader->findClass('OC_Files'));
}
- public function testLoadTestNamespace() {
+ public function testLoadTestTestCase() {
$this->assertEquals([
- \OC::$SERVERROOT . '/tests/lib/foo/bar.php'
- ], $this->loader->findClass('Test\Foo\Bar'));
+ \OC::$SERVERROOT . '/tests/lib/TestCase.php'
+ ], $this->loader->findClass('Test\TestCase'));
}
- public function testLoadTest() {
+ public function testLoadTestNamespace() {
$this->assertEquals([
\OC::$SERVERROOT . '/tests/lib/foo/bar.php'
- ], $this->loader->findClass('Test_Foo_Bar'));
+ ], $this->loader->findClass('Test\Foo\Bar'));
}
public function testLoadCore() {