1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
-
- namespace Tests\Feature;
-
- use App\Models\User;
- use Illuminate\Foundation\Testing\RefreshDatabase;
- use Livewire\Livewire;
- use Tests\TestCase;
- use Wallo\FilamentCompanies\Features;
- use Wallo\FilamentCompanies\Http\Livewire\DeleteUserForm;
-
- class DeleteAccountTest extends TestCase
- {
- use RefreshDatabase;
-
- public function test_user_accounts_can_be_deleted(): void
- {
- if (! Features::hasAccountDeletionFeatures()) {
- $this->markTestSkipped('Account deletion is not enabled.');
-
- return;
- }
-
- $this->actingAs($user = User::factory()->create());
-
- $component = Livewire::test(DeleteUserForm::class)
- ->set('password', 'password')
- ->call('deleteUser');
-
- $this->assertNull($user->fresh());
- }
-
- public function test_correct_password_must_be_provided_before_account_can_be_deleted(): void
- {
- if (! Features::hasAccountDeletionFeatures()) {
- $this->markTestSkipped('Account deletion is not enabled.');
-
- return;
- }
-
- $this->actingAs($user = User::factory()->create());
-
- Livewire::test(DeleteUserForm::class)
- ->set('password', 'wrong-password')
- ->call('deleteUser')
- ->assertHasErrors(['password']);
-
- $this->assertNotNull($user->fresh());
- }
- }
|