Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function testHash(){
- $hash = Mockery::mock('HashLogin');
- $hash->shouldReceive('checkHash')->once();
- $this->app->instance('HashLogin', $hash);
- $this->call('GET', 'login/hash/c3e144adfe8133343b37d0d95f987d87b2d87a24');
- }
- public function __construct(User $user, HashLogin $hashlogin){
- $this->user = $user;
- $this->hashlogin = $hashlogin;
- $this->ip_direct = array_key_exists("REMOTE_ADDR",$_SERVER) ? $_SERVER["REMOTE_ADDR"] : null;
- $this->ip_elb = array_key_exists("HTTP_X_FORWARDED_FOR",$_SERVER) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : null;
- $this->beforeFilter(function()
- {
- if(Auth::check()){return Redirect::to('/');}
- });
- }
- public function getHash($code){
- $hash = $this->hashlogin->checkHash($code);
- if(!$hash){
- return $this->badLogin('Invalid Login');
- }
- $user = $this->user->getFromLegacy($hash->getLegacyUser());
- $hash->cleanup();
- $this->login($user);
- return Redirect::intended('/');
- }
- public function testLoginSuccessfulWithAuthTrue(){
- Input::shouldReceive('get')->with('username')->once()->andReturn('user');
- Input::shouldReceive('get')->with('password')->once()->andReturn('1234');
- Auth::shouldReceive('attempt')->once()->andReturn(true);
- $user = Mockery::mock('User');
- $user->shouldReceive('buildRBAC')->once();
- Auth::shouldReceive('user')->once()->andReturn($user);
- $this->call('POST', 'login');
- $this->assertRedirectedToRoute('index');
- }
- public function postIndex(){
- $username = Input::get("username");
- $pass = Input::get('password');
- if(Auth::attempt(array('username' => $username, 'password' => $pass))){
- Auth::user()->buildRBAC();
- }else{
- $user = $this->user->checkForLegacyUser($username);
- if($user){
- $this->login($user);
- }else{
- return Redirect::back()->withInput()->with('error', "Invalid credentials.");
- }
- }
- return Redirect::intended('/');
- }
- MockeryExceptionInvalidCountException: Method get("username") from Mockery_5_Illuminate_Http_Request should be called exactly 1 times but called 0 times."
- $hash = Mockery::mock('AppModelsEloquentHashLogin');
- $this->app->instance('AppModelsEloquentHashLogin', $hash);
Add Comment
Please, Sign In to add comment