diff --git a/composer.json b/composer.json index 12d74c6d..b538ce8a 100644 --- a/composer.json +++ b/composer.json @@ -14,11 +14,6 @@ "OCA\\SoftwareCatalog\\": "lib/" } }, - "autoload-dev": { - "psr-4": { - "OCA\\OpenRegister\\": "tests/Stubs/" - } - }, "scripts": { "post-install-cmd": [ "@composer bin all install --ansi" diff --git a/tests/bootstrap.php b/tests/bootstrap.php index fd6806ed..31f7ba7c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -36,10 +36,23 @@ // Load all enabled apps \OC_App::loadApps(); - + // Load our specific app \OC_App::loadApp('softwarecatalog'); - + // Clear hooks for testing OC_Hook::clear(); } + +// OpenRegister test stubs. The real OCA\OpenRegister\Db\ObjectEntity has +// __call magic getters that PHPUnit can't configure on a mock, so the unit +// tests use the explicit stub in tests/Stubs/. It is loaded HERE — not via a +// composer `autoload-dev` PSR-4 mapping of the foreign `OCA\OpenRegister\` +// namespace, which would shadow the real OpenRegister classes in any +// deployment whose vendor/ includes dev autoload entries (breaking every +// OR-backed app). Only loaded when OpenRegister isn't actually installed. +if (!class_exists('OCA\\OpenRegister\\Db\\ObjectEntity')) { + foreach (glob(__DIR__ . '/Stubs/{,**/}*.php', GLOB_BRACE) ?: [] as $stub) { + require_once $stub; + } +}