0

All documentation that I have found refers to the Laravel helper actingAs() but this requires me to be using Laravel's native Auth package and I'm using Cartalyst's Sentinel and so can't use actingAs().

Has anyone found a way around this?

Ben
  • 311
  • 1
  • 2
  • 12

1 Answers1

1

You can use the login method of Sentinel facade.

$user = Sentinel::getUserById(1);
$rememberMe = true;
Sentinel::login($user, $rememberMe);

You can also use setUser method of Sentinel facade. Note this doesn't log the user in.

$user = Sentinel::getUserById(1);
Sentinel::setUser($user);
MTran
  • 1,799
  • 2
  • 17
  • 21
  • How to use a repository result with actingAs()?. My error is Argument 1 passed to Illuminate\Foundation\Testing\TestCase::actingAs() must implement interface Illuminate\Contracts\Auth\Authenticatable, instance of Illuminate\Database\Eloquent\Collection given, – Sahal Nov 06 '20 at 08:18