$namespaces = [__NAMESPACE__ => __DIR__ . '/' . __NAMESPACE__]; //find all modules tests foler and namespace $modulesPath = self::findParentPath('module'); foreach (self::$modulesToTest as $moduleToTest) { $moduleToTestName = $moduleToTest . "Test"; $namespaces = array_merge($namespaces, [$moduleToTestName => $modulesPath . DIRECTORY_SEPARATOR . $moduleToTest . DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR . $moduleToTestName]); } include $zf2Path . '/Zend/Loader/AutoloaderFactory.php'; AutoloaderFactory::factory(['Zend\\Loader\\StandardAutoloader' => ['autoregister_zf' => true, 'namespaces' => $namespaces]]); } /** * @param $path * @return bool|string */ protected static function findParentPath($path) { $dir = __DIR__; $previousDir = '.'; while (!is_dir($dir . '/' . $path)) { $dir = dirname($dir); if ($previousDir === $dir) { return false; } $previousDir = $dir; } return $dir . '/' . $path; } } BootstrapTests::init(); BootstrapTests::chroot();
/** * @return ServiceManager */ protected function getServiceManager() { $sm = \BootstrapTests::getServiceManager(); return $sm; }