mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
Added user and organization deletion system; Added coverage annotations
This commit is contained in:
committed by
Constantin Graf
parent
8857befc6c
commit
86f5ea47bb
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user