Install Pest

This commit is contained in:
Bob Molitor committed 2025-10-16 14:22:58 +02:00
1 parent 81a98dd9f4
commit e8db0d9a5a
16 files changed
+1618 -805

No files matched your search

+48 -62
View File
@@ -1,89 +1,75 @@
<?php
namespace Tests\Feature\Settings;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Livewire\Volt\Volt;
use Tests\TestCase;
class ProfileUpdateTest extends TestCase
{
use RefreshDatabase;
test('profile page is displayed', function () {
$this->actingAs($user = User::factory()->create());
public function test_profile_page_is_displayed(): void
{
$this->actingAs($user = User::factory()->create());
$this->get(route('profile.edit'))->assertOk();
});
$this->get(route('profile.edit'))->assertOk();
}
test('profile information can be updated', function () {
$user = User::factory()->create();
public function test_profile_information_can_be_updated(): void
{
$user = User::factory()->create();
$this->actingAs($user);
$this->actingAs($user);
$response = Volt::test('settings.profile')
->set('name', 'Test User')
->set('email', 'test@example.com')
->call('updateProfileInformation');
$response = Volt::test('settings.profile')
->set('name', 'Test User')
->set('email', 'test@example.com')
->call('updateProfileInformation');
$response->assertHasNoErrors();
$response->assertHasNoErrors();
$user->refresh();
$user->refresh();
expect($user->name)->toEqual('Test User');
expect($user->email)->toEqual('test@example.com');
expect($user->email_verified_at)->toBeNull();
});
$this->assertEquals('Test User', $user->name);
$this->assertEquals('test@example.com', $user->email);
$this->assertNull($user->email_verified_at);
}
test('email verification status is unchanged when email address is unchanged', function () {
$user = User::factory()->create();
public function test_email_verification_status_is_unchanged_when_email_address_is_unchanged(): void
{
$user = User::factory()->create();
$this->actingAs($user);
$this->actingAs($user);
$response = Volt::test('settings.profile')
->set('name', 'Test User')
->set('email', $user->email)
->call('updateProfileInformation');
$response = Volt::test('settings.profile')
->set('name', 'Test User')
->set('email', $user->email)
->call('updateProfileInformation');
$response->assertHasNoErrors();
$response->assertHasNoErrors();
expect($user->refresh()->email_verified_at)->not->toBeNull();
});
$this->assertNotNull($user->refresh()->email_verified_at);
}
test('user can delete their account', function () {
$user = User::factory()->create();
public function test_user_can_delete_their_account(): void
{
$user = User::factory()->create();
$this->actingAs($user);
$this->actingAs($user);
$response = Volt::test('settings.delete-user-form')
->set('password', 'password')
->call('deleteUser');
$response = Volt::test('settings.delete-user-form')
->set('password', 'password')
->call('deleteUser');
$response
->assertHasNoErrors()
->assertRedirect('/');
$response
->assertHasNoErrors()
->assertRedirect('/');
expect($user->fresh())->toBeNull();
expect(auth()->check())->toBeFalse();
});
$this->assertNull($user->fresh());
$this->assertFalse(auth()->check());
}
test('correct password must be provided to delete account', function () {
$user = User::factory()->create();
public function test_correct_password_must_be_provided_to_delete_account(): void
{
$user = User::factory()->create();
$this->actingAs($user);
$this->actingAs($user);
$response = Volt::test('settings.delete-user-form')
->set('password', 'wrong-password')
->call('deleteUser');
$response = Volt::test('settings.delete-user-form')
->set('password', 'wrong-password')
->call('deleteUser');
$response->assertHasErrors(['password']);
$response->assertHasErrors(['password']);
$this->assertNotNull($user->fresh());
}
}
expect($user->fresh())->not->toBeNull();
});