public function testGetVariablesGoodLogin() { $_REQUEST['email'] = $this->credentials['email']; $_REQUEST['passwd'] = $this->credentials['password']; $sentry = m::mock('Cartalyst\\Sentry\\Sentry'); $sentry->shouldReceive('authenticate')->with($this->credentials, false)->once()->andReturn($user = m::mock('Cartalyst\\Sentry\\Users\\UserInterface')); $login = new Login($sentry); $variables = $login->getViewVariables(); $this->assertArrayHasKey('redirect', $variables); }
public function testGetViewVariablesAuthenticatesIfRequestParamsDetectedAndReturnsFailureVariables() { $faker = $this->getFaker(); $email = $faker->email; $password = $faker->password; $sentry = $this->getSentryMock(); $sentry->shouldReceive('authenticate')->once()->with(['email' => $email, 'password' => $password], false)->andThrow(new UserNotFoundException()); $login = new Login($sentry); $_REQUEST['email'] = $email; $_REQUEST['passwd'] = $password; $viewVariables = $login->getViewVariables(); $expected = ['errorMessage' => 'Invalid Email or Password', 'email' => $email]; $this->assertSame($expected, $viewVariables); }