我有一个实现的模型:
\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',
),
),