Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Make SessionGuard::onceUsingId() return user instance #13434

Merged
merged 1 commit into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Illuminate/Auth/SessionGuard.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ protected function updateSession($id)
*
* @param mixed $id
* @param bool $remember
* @return \Illuminate\Contracts\Auth\Authenticatable
* @return \Illuminate\Contracts\Auth\Authenticatable|false
*/
public function loginUsingId($id, $remember = false)
{
Expand All @@ -487,7 +487,7 @@ public function loginUsingId($id, $remember = false)
* Log the given user ID into the application without sessions or cookies.
*
* @param mixed $id
* @return bool
* @return \Illuminate\Contracts\Auth\Authenticatable|false
*/
public function onceUsingId($id)
{
Expand All @@ -496,7 +496,7 @@ public function onceUsingId($id)
if (! is_null($user)) {
$this->setUser($user);

return true;
return $user;
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion tests/Auth/AuthGuardTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ public function testOnceUsingIdSetsUser()
$guard->getProvider()->shouldReceive('retrieveById')->once()->with(10)->andReturn($user);
$guard->shouldReceive('setUser')->once()->with($user);

$this->assertTrue($guard->onceUsingId(10));
$this->assertEquals($user, $guard->onceUsingId(10));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assertSame would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@GrahamCampbell Agree. Do you want to make the change? (lines 262 and 285)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact there are a few other occurrences of assertEquals($user, ...) in this file. Not really worth bothering about this, though.

}

public function testOnceUsingIdFailure()
Expand Down