user affiliation schema completed

This commit is contained in:
Giuseppe Naponiello
2026-06-24 16:30:57 +02:00
parent 6a07c3e922
commit 96b0dc76aa
6 changed files with 100 additions and 42 deletions

View File

@@ -339,6 +339,28 @@ class UserAffiliationControllerTest extends TestCase
$this->assertNotSoftDeleted($trashed);
}
public function test_restore_succeeds_for_a_closed_affiliation_even_when_another_one_is_open(): void
{
$this->actingAs($this->operationalUser(), 'sanctum');
$institution = Institution::factory()->create();
$user = User::factory()->create();
$trashed = UserAffiliation::factory()->create([
'institution_id' => $institution->id,
'user_id' => $user->id,
'end_year' => 2019,
]);
$trashed->delete();
UserAffiliation::factory()->create([
'institution_id' => $institution->id,
'user_id' => $user->id,
'end_year' => null,
]);
$this->postJson(self::BASE_ROUTE."/{$trashed->id}/restore")->assertOk();
$this->assertNotSoftDeleted($trashed);
}
public function test_operational_user_can_force_delete_an_affiliation(): void
{
$this->actingAs($this->operationalUser(), 'sanctum');