-
Notifications
You must be signed in to change notification settings - Fork 308
/
Copy pathRecoveryCodeControllerTest.php
42 lines (31 loc) · 1.09 KB
/
RecoveryCodeControllerTest.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
<?php
namespace Laravel\Fortify\Tests;
use Illuminate\Foundation\Auth\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Event;
use Laravel\Fortify\Events\RecoveryCodesGenerated;
class RecoveryCodeControllerTest extends OrchestraTestCase
{
use RefreshDatabase;
public function test_new_recovery_codes_can_be_generated()
{
Event::fake();
$user = TestTwoFactorRecoveryCodeUser::forceCreate([
'name' => 'Taylor Otwell',
'email' => '[email protected]',
'password' => bcrypt('secret'),
]);
$response = $this->withoutExceptionHandling()->actingAs($user)->postJson(
'/user/two-factor-recovery-codes'
);
$response->assertStatus(200);
Event::assertDispatched(RecoveryCodesGenerated::class);
$user->fresh();
$this->assertNotNull($user->two_factor_recovery_codes);
$this->assertIsArray(json_decode(decrypt($user->two_factor_recovery_codes), true));
}
}
class TestTwoFactorRecoveryCodeUser extends User
{
protected $table = 'users';
}