Fixed permissions; Added tests for permission store

This commit is contained in:
Constantin Graf
2024-04-24 15:07:39 +02:00
committed by Constantin Graf
parent 75a3404f46
commit 267adf52ca
6 changed files with 170 additions and 25 deletions

View File

@@ -6,7 +6,6 @@ namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Jetstream\Features;
use Tests\TestCase;
class DeleteAccountTest extends TestCase
@@ -15,31 +14,32 @@ class DeleteAccountTest extends TestCase
public function test_user_accounts_can_be_deleted(): void
{
if (! Features::hasAccountDeletionFeatures()) {
$this->markTestSkipped('Account deletion is not enabled.');
}
$this->actingAs($user = User::factory()->create());
// Arrange
$user = User::factory()->create();
$this->actingAs($user);
// Act
$response = $this->delete('/user', [
'password' => 'password',
]);
// Assert
$response->assertStatus(302);
$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.');
}
$this->actingAs($user = User::factory()->create());
// Arrange
$user = User::factory()->create();
$this->actingAs($user);
// Act
$response = $this->delete('/user', [
'password' => 'wrong-password',
]);
// Assert
$this->assertNotNull($user->fresh());
}
}