Added user and organization deletion system; Added coverage annotations

This commit is contained in:
Constantin Graf
2024-06-07 19:17:40 +02:00
committed by Constantin Graf
parent 8857befc6c
commit 86f5ea47bb
65 changed files with 2651 additions and 135 deletions

View File

@@ -4,6 +4,9 @@ declare(strict_types=1);
namespace Tests\Feature;
use App\Enums\Role;
use App\Models\Member;
use App\Models\Organization;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@@ -42,4 +45,24 @@ class DeleteAccountTest extends TestCase
// Assert
$this->assertNotNull($user->fresh());
}
public function test_user_account_can_not_be_deleted_if_attached_to_a_organization_with_multiple_users(): void
{
// Arrange
$user = User::factory()->create();
$organization = Organization::factory()->withOwner($user)->create();
$userMember = Member::factory()->forOrganization($organization)->forUser($user)->role(Role::Owner)->create();
$otherUser = User::factory()->create();
$otherMember = Member::factory()->forOrganization($organization)->forUser($otherUser)->role(Role::Admin)->create();
$this->actingAs($user);
// Act
$response = $this->delete('/user', [
'password' => 'password',
]);
// Assert
$response->assertInvalid(['password']);
$this->assertNotNull($user->fresh());
}
}