mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-16 16:41:03 +02:00
Fix and complete tests
This commit is contained in:
67
tests/Feature/Http/Auth/WebAuthnDeviceLostControllerTest.php
Normal file
67
tests/Feature/Http/Auth/WebAuthnDeviceLostControllerTest.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature\Auth;
|
||||
|
||||
use App\Models\User;
|
||||
use Tests\FeatureTestCase;
|
||||
use Illuminate\Support\Facades\Notification;
|
||||
|
||||
class WebAuthnDeviceLostControllerTest extends FeatureTestCase
|
||||
{
|
||||
/**
|
||||
* @var \App\Models\User
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_sendRecoveryEmail_sends_notification_on_success()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
$response = $this->json('POST', '/webauthn/lost', [
|
||||
'email' => $this->user->email,
|
||||
]);
|
||||
|
||||
Notification::assertSentTo($this->user, \DarkGhostHunter\Larapass\Notifications\AccountRecoveryNotification::class);
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertJsonStructure([
|
||||
'message'
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_sendRecoveryEmail_does_not_send_anything_on_error()
|
||||
{
|
||||
Notification::fake();
|
||||
|
||||
$response = $this->json('POST', '/webauthn/lost', [
|
||||
'email' => 'bad@email.com',
|
||||
]);
|
||||
|
||||
Notification::assertNothingSent();
|
||||
|
||||
$response->assertStatus(422)
|
||||
->assertJsonValidationErrors([
|
||||
'email'
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user