如何测试acl中的控制器。
Zend\ServiceManager\Exception\ServiceNotCreatedException: An exception was raised while creating "acl"; no instance returned
我的嘲笑代码
protected function mockLogin()
{
$authService = $this->getMock('Zend\Authentication\AuthenticationService');
$authService->expects($this->any())
->method('getIdentity')
->will($this->returnValue(1));
$authService->expects($this->any())
->method('hasIdentity')
->will($this->returnValue(true));
$authService->expects($this->any())
->method('getRole')
->will($this->returnValue(2));
$this->getApplicationServiceLocator()->setAllowOverride(true);
$this->getApplicationServiceLocator()->setService('Zend\Authentication\AuthenticationService',
$authService);
}
public function testIndexActionCanBeAccessed()
{
$this->mockLogin();
$this->dispatch('/');
$this->assertResponseStatusCode(200);
$this->assertModuleName('Application');
$this->assertControllerName('Application\Controller\Index');
$this->assertControllerClass('IndexController');
$this->assertMatchedRouteName('application');
}