PasswordConfirmationTest.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Tests\Feature;
  3. use App\Models\User;
  4. use Illuminate\Foundation\Testing\RefreshDatabase;
  5. use Laravel\Jetstream\Features;
  6. use Tests\TestCase;
  7. class PasswordConfirmationTest extends TestCase
  8. {
  9. use RefreshDatabase;
  10. public function test_confirm_password_screen_can_be_rendered()
  11. {
  12. $user = Features::hasTeamFeatures()
  13. ? User::factory()->withPersonalTeam()->create()
  14. : User::factory()->create();
  15. $response = $this->actingAs($user)->get('/user/confirm-password');
  16. $response->assertStatus(200);
  17. }
  18. public function test_password_can_be_confirmed()
  19. {
  20. $user = User::factory()->create();
  21. $response = $this->actingAs($user)->post('/user/confirm-password', [
  22. 'password' => 'password',
  23. ]);
  24. $response->assertRedirect();
  25. $response->assertSessionHasNoErrors();
  26. }
  27. public function test_password_is_not_confirmed_with_invalid_password()
  28. {
  29. $user = User::factory()->create();
  30. $response = $this->actingAs($user)->post('/user/confirm-password', [
  31. 'password' => 'wrong-password',
  32. ]);
  33. $response->assertSessionHasErrors();
  34. }
  35. }