diff --git a/lib/base.php b/lib/base.php
index 51f4d819ab1ed4146f0c4f3441d2371ea5971e92..80b1a2bafcd71fc39049f0a09261b5588fdf7f2c 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -488,9 +488,10 @@ class OC {
 			OC::$SERVERROOT . '/settings',
 			OC::$SERVERROOT . '/ocs',
 			OC::$SERVERROOT . '/ocs-provider',
-			OC::$SERVERROOT . '/3rdparty',
-			OC::$SERVERROOT . '/tests',
 		]);
+		if (defined('PHPUNIT_RUN')) {
+			self::$loader->addValidRoot(OC::$SERVERROOT . '/tests');
+		}
 		spl_autoload_register(array(self::$loader, 'load'));
 		$loaderEnd = microtime(true);