$modulePaths = array(dirname($rootPath)); if (isset($additionalModulePaths)) { $modulePaths = array_merge($modulePaths, $additionalModulePaths); } // Load this module and defined dependencies $modules = array($moduleName); if (isset($moduleDependencies)) { $modules = array_merge($modules, $moduleDependencies); } $listenerOptions = new Zend\ModuleManager\Listener\ListenerOptions(array('module_paths' => $modulePaths)); $defaultListeners = new Zend\ModuleManager\Listener\DefaultListenerAggregate($listenerOptions); $sharedEvents = new Zend\EventManager\SharedEventManager(); $moduleManager = new \Zend\ModuleManager\ModuleManager($modules); $moduleManager->getEventManager()->setSharedManager($sharedEvents); $moduleManager->getEventManager()->attachAggregate($defaultListeners); $moduleManager->loadModules(); if (method_exists($moduleTestCaseClassname, 'setLocator')) { $config = $defaultListeners->getConfigListener()->getMergedConfig(); $di = new \Zend\Di\Di(); $di->instanceManager()->addTypePreference('Zend\\Di\\LocatorInterface', $di); if (isset($config['di'])) { $diConfig = new \Zend\Di\Config($config['di']); $diConfig->configure($di); } $routerDiConfig = new \Zend\Di\Config(array('definition' => array('class' => array('Zend\\Mvc\\Router\\RouteStackInterface' => array('instantiator' => array('Zend\\Mvc\\Router\\Http\\TreeRouteStack', 'factory')))))); $routerDiConfig->configure($di); call_user_func_array($moduleTestCaseClassname . '::setLocator', array($di)); } // When this is in global scope, PHPUnit catches exception: // Exception: Zend\Stdlib\PriorityQueue::serialize() must return a string or NULL unset($moduleManager, $sharedEvents);
<?php use Zend\Config\Factory as ConfigFactory; //$mm = new \Zend\ModuleManager\ModuleManager(include APPLICATION_PATH . '/config/autoload/' . APP_NAME . '/modules.php'); $mm = new \Zend\ModuleManager\ModuleManager(['Liba', 'buh']); $la = new \Zend\ModuleManager\Listener\DefaultListenerAggregate(); $mm->getEventManager()->attachAggregate($la); $mm->loadModules(); /** * @var $config \Zend\Config\Config */ $config = $la->getConfigListener()->getMergedConfig(); //$config->merge($cfg); //return $config->toArray(); return ['services' => ['config' => array_merge(['db' => ['driver' => 'pdo', 'dsn' => 'mysql:dbname=dondrakon_1ctest;host=92.53.118.41;', 'username' => 'dondrakon_1ctest', 'password' => 'Sum23rak', 'driver_options' => [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8']]], $config->toArray())], 'invokables' => ['Zend\\Expressive\\Router\\RouterInterface' => Zend\Expressive\Router\FastRouteRouter::class, 'auth' => Zend\Authentication\AuthenticationService::class, 'store' => \Liba\Store::class, 'sys_types' => \Liba\Sys\Types::class, 'sys_actions' => \Liba\Sys\Actions::class, 'profileFlag' => \buh\Ds\ProfileFlag::class, 'profile' => \buh\Ds\Profile::class, 'subject' => \buh\Ds\Subject::class, 'debtentrosumma' => \buh\Ds\debtentrosumma::class, 'debtentrogoodcount' => \buh\Ds\debtentrogoodcount::class, 'entrodebtsumma' => \buh\Ds\entrodebtsumma::class, 'entrodebtgoodcount' => \buh\Ds\entrodebtgoodcount::class, 'costCategory' => \buh\Ds\CostCategory::class, 'costSource' => \buh\Ds\CostSource::class, 'costKind' => \buh\Ds\CostKind::class, 'productCategory' => \buh\Ds\ProductCategory::class, 'unit' => \buh\Ds\Unit::class, 'company' => \buh\Ds\Company::class, 'department' => \buh\Ds\Department::class, 'product' => \buh\Ds\Product::class, 'money' => \buh\Ds\Money::class, 'v_money' => \buh\Ds\MoneyView::class, 'good' => \buh\Ds\Good::class, 'bought' => \buh\Ds\Bought::class, 'deal' => \buh\Ds\Deal::class, 'subanalytic' => \buh\Ds\Subanalytic::class, 'auto' => \buh\Ds\Auto::class], 'factories' => [APP_NAME => 'Zend\\Expressive\\Container\\ApplicationFactory', 'Zend\\Db\\Adapter\\Adapter' => 'Zend\\Db\\Adapter\\AdapterServiceFactory'], 'aliases' => ['db' => 'Zend\\Db\\Adapter\\Adapter'], 'abstract_factories' => ['Platform\\Factory', 'Platform\\Dic']];