public function testAuthenticateSuccess() { $role = new Role('customer', null); $user = new User('*****@*****.**', 'john', 'John', 'Smith', 'password'); $user->activate(); $user->addRole($role); $identity = $this->authenticator->authenticate(['authenticator' => Authenticator::AUTH_EMAIL, 'user' => $user, 'password' => 'password']); $this->assertEquals(new Identity(null, ['customer']), $identity); }
public function testAuthenticateWithEmail() { $identity = new Identity(1, ['customer']); $this->userStorage->shouldReceive('isAuthenticated')->once()->andReturn(false); $this->userStorage->shouldReceive('setIdentity')->once()->with(null); $this->authenticator->shouldReceive('authenticateWithEmail')->once()->with('*****@*****.**', 'password')->andReturn($identity); $this->userStorage->shouldReceive('setIdentity')->once()->with($identity); $this->userStorage->shouldReceive('setAuthenticated')->once()->with(true); $this->user->authenticateWithEmail('*****@*****.**', 'password'); }