-
Notifications
You must be signed in to change notification settings - Fork 43
/
LoginTest.php
46 lines (35 loc) · 1.22 KB
/
LoginTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
namespace MagicLink\Test\Actions;
use Illuminate\Support\Facades\Auth;
use MagicLink\Actions\LoginAction;
use MagicLink\MagicLink;
use MagicLink\Test\TestCase;
use MagicLink\Test\TestSupport\CustomAutenticable;
use MagicLink\Test\TestSupport\CustomUserProvider;
use MagicLink\Test\TestSupport\User;
class LoginTest extends TestCase
{
public function test_auth()
{
$magiclink = MagicLink::create(new LoginAction(User::first()));
$this->get($magiclink->url)
->assertStatus(302)
->assertRedirect('/');
$this->assertAuthenticatedAs(User::first());
}
public function test_auth_custom()
{
Auth::provider('custom_provider', function ($app, array $config) {
return new CustomUserProvider($app, $config);
});
config()->set('auth.providers.custom', [
'driver' => 'custom_provider',
]);
config()->set('auth.guards.web.provider', 'custom');
$magiclink = MagicLink::create(new LoginAction(new CustomAutenticable('user_1')));
$this->get($magiclink->url)
->assertStatus(302)
->assertRedirect('/');
$this->assertAuthenticatedAs(new CustomAutenticable('user_1'));
}
}