public function createService(ServiceLocatorInterface $serviceLocator) { $authenticationService = $serviceLocator->get('UghAuthentication\\Authentication\\AuthenticationService'); $authenticationValidator = new Authentication(); $authenticationValidator->setIdentity('username'); $authenticationValidator->setCredential('password'); $authenticationValidator->setService($authenticationService); return $authenticationValidator; }
/** * * @dataProvider authenticationValidationMessages */ public function testErrorMessages($errorCode, $errorKey, $errorMessage) { $authenticationResult = new Result($errorCode, 'testuser'); $authenticationServiceMock = $this->getMock('UghAuthentication\\Authentication\\AuthenticationServiceInterface'); $authenticationServiceMock->expects($this->once())->method('authenticate')->will($this->returnValue($authenticationResult)); $authenticationValidator = new Authentication(); $authenticationValidator->setService($authenticationServiceMock); $authenticationValidator->setIdentity('username'); $result = $authenticationValidator->isValid(); $this->assertFalse($result); $authenticationValidationMessages = $authenticationValidator->getMessages(); $this->assertSame($errorMessage, $authenticationValidationMessages[$errorKey]); }