Skip to content

Commit

Permalink
Test that the authenticated user has the same type as well
Browse files Browse the repository at this point in the history
  • Loading branch information
sileence committed Apr 26, 2016
1 parent 702ef58 commit b530361
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,15 @@ protected function isAuthenticated($guard = null)
*/
public function seeIsAuthenticatedAs($user, $guard = null)
{
$auth = $this->app->make('auth')->guard($guard);
$expected = $this->app->make('auth')->guard($guard)->user();

$this->assertInstanceOf(
get_class($expected), $user,
'The logged in user is not the same'
);

$this->assertSame(
$auth->user()->getAuthIdentifier(), $user->getAuthIdentifier(),
$expected->getAuthIdentifier(), $user->getAuthIdentifier(),
'The logged in user is not the same'
);

Expand Down
10 changes: 7 additions & 3 deletions tests/Foundation/FoundationAuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,18 @@ public function testDontSeeIsAuthenticated()

public function testSeeIsAuthenticatedAs()
{
$user = m::mock(Authenticatable::class);
$user->shouldReceive('getAuthIdentifier')
$expected = m::mock(Authenticatable::class);
$expected->shouldReceive('getAuthIdentifier')
->andReturn('1');

$this->mockGuard()
->shouldReceive('user')
->once()
->andReturn($user);
->andReturn($expected);

$user = m::mock(Authenticatable::class);
$user->shouldReceive('getAuthIdentifier')
->andReturn('1');

$this->seeIsAuthenticatedAs($user);
}
Expand Down

0 comments on commit b530361

Please sign in to comment.