Phpunit ZF2-服务经理和;getServiceConfig问题-无法获取或创建实例

Phpunit ZF2-服务经理和;getServiceConfig问题-无法获取或创建实例,phpunit,zend-framework2,Phpunit,Zend Framework2,我在尝试使用ZF2的身份验证服务时遇到了一些问题。我必须使用以下Module.php getServiceConfig函数: <?php public function getServiceConfig() { return array( 'factories' => array( 'Auth\Model\CustomerTable' => function($sm) { $tableGatew

我在尝试使用ZF2的身份验证服务时遇到了一些问题。我必须使用以下Module.php getServiceConfig函数:

<?php

public function getServiceConfig()
{
    return array(
        'factories' => array(
            'Auth\Model\CustomerTable' =>  function($sm) {
                $tableGateway = $sm->get('CustomerTableGateway');
                $table = new CustomerTable($tableGateway);
                return $table;
            },
            'CustomerTableGateway' => function($sm) {
                $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                $resultSetPrototype = new ResultSet();
                $resultSetPrototype->setArrayObjectPrototype(new Customer()); // prototype pattern implemented.
                return new TableGateway('customer', $dbAdapter, null, $resultSetPrototype);
            },
            'Auth\Model\AuthStorage' => function($sm){
                return new \Auth\Model\AuthStorage('jamietech');  
            },
            'AuthService' => function($sm) {
                $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                $dbTableAuthAdapter  = new DbTableAuthAdapter($dbAdapter, 
                                          'customer','username','password');

                $authService = new AuthenticationService();
                $authService->setAdapter($dbTableAuthAdapter);
                $authService->setStorage($sm->get('Auth\Model\AuthStorage'));

                return $authService;
            },
        ),
    );
}
在运行-process隔离命令时,登录和注销都会出现此错误:

"Serialization of closure is not allowed in: C;\Users\-----\AppData\Local\Temp\-----
如果有人能帮忙,那就太好了。我是ZF noob,所以尽量不要太苛刻

编辑:顺便说一句,global.php文件包括ZF2教程应用程序中说明的service_manager适配器工厂

谢谢大家!! 杰米·麦克劳克兰

你检查过这些吗:

  • 自动加载_classmap.php(用于您的模块)
  • module.config.php中
像这样

service_manager' => array(
 'aliases' => array(    
  'mymodule-ZendDbAdapter' => 'Zend\Db\Adapter\Adapter',
  ),
);

我希望它能帮助你找到答案

嗨,我真的很感谢你的回复。我的autoload_classmap.php只是一个空数组,module.config包含服务管理器,其适配器包含在global.php文件中。我仍然不确定是什么导致了问题。此外,我可以在模块类中的AuthTableGateway工厂中创建一个适配器,但它不允许我在AuthService类中创建另一个适配器。我太糊涂了!我也有同样的问题。你是怎么解决的?
"Serialization of closure is not allowed in: C;\Users\-----\AppData\Local\Temp\-----
service_manager' => array(
 'aliases' => array(    
  'mymodule-ZendDbAdapter' => 'Zend\Db\Adapter\Adapter',
  ),
);