thanks, good idea! is there an easy way to mock the auth? – Ron
I'm posting this as an answer, because its too much to press it into a comment. Yes, there is an easy way to mock the AuthenticationService class. First of all, check the docs on Stubs / Mocks.
What you need to do is to create the mock from Zend\Authentication\AuthenticationService and configure it to pretend to contain an identity.
public function testSomethingThatRequiresAuth()
{
$authMock = $this->getMock('Zend\Authentication\AuthenticationService');
$authMock->expects($this->any())
->method('hasIdentity')
->will($this->returnValue(true));
$authMock->expects($this->any())
->method('getIdentity')
->will($this->returnValue($identityMock));
// Assign $authMock to the part where Authentication is required.
}
In this example, a variable $identityMock
is required to be defined previously. It could be a mock of your user model class or something like that.
Note that I haven't tested it, so it might not work instantly. However, its just supposed to show you the direction.