mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-13 06:56:48 +00:00
Laravel Jetstream install
This commit is contained in:
46
tests/Feature/DeleteAccountTest.php
Normal file
46
tests/Feature/DeleteAccountTest.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Laravel\Jetstream\Features;
|
||||
use Laravel\Jetstream\Http\Livewire\DeleteUserForm;
|
||||
use Livewire\Livewire;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DeleteAccountTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_user_accounts_can_be_deleted()
|
||||
{
|
||||
if (! Features::hasAccountDeletionFeatures()) {
|
||||
return $this->markTestSkipped('Account deletion is not enabled.');
|
||||
}
|
||||
|
||||
$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()
|
||||
{
|
||||
if (! Features::hasAccountDeletionFeatures()) {
|
||||
return $this->markTestSkipped('Account deletion is not enabled.');
|
||||
}
|
||||
|
||||
$this->actingAs($user = User::factory()->create());
|
||||
|
||||
Livewire::test(DeleteUserForm::class)
|
||||
->set('password', 'wrong-password')
|
||||
->call('deleteUser')
|
||||
->assertHasErrors(['password']);
|
||||
|
||||
$this->assertNotNull($user->fresh());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user