Zend framework2 通过phpunit访问时,ServiceManager无法获取全局配置的记录器
我有一个实现以下功能的模型:Zend framework2 通过phpunit访问时,ServiceManager无法获取全局配置的记录器,zend-framework2,Zend Framework2,我有一个实现以下功能的模型: \Zend\ServiceManager\ServiceLocatorAwareInterface 该模型依赖于\configs\autoload\global.php中定义的记录器,并通过执行以下操作进行检索: $this->getServiceLocator()->get("Zend\Log") 如果我在一个网页上,这很有用,但是在phpunit中,相同的代码会在消息中中断: Zend\ServiceManager\Exception\Servi
\Zend\ServiceManager\ServiceLocatorAwareInterface
该模型依赖于\configs\autoload\global.php中定义的记录器,并通过执行以下操作进行检索:
$this->getServiceLocator()->get("Zend\Log")
如果我在一个网页上,这很有用,但是在phpunit中,相同的代码会在消息中中断:
Zend\ServiceManager\Exception\ServiceNotFoundException:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for Zend\Log"
为什么服务管理器在从web运行时能够获取记录器,而不是从phpunit
Testconfig.php.dist包含:
'module_listener_options' => array(
'config_glob_paths' => array(
'../../../../config/autoload/{,*.}{global,local}.php',
),
'module_paths' => array(
'module',
'vendor',
),
),
TestConfig.php.dist中的路径错误。应该是的
../../../config/autoload/{,*.}{global,local}.php',