markTestSkipped('Company invitations not enabled.'); return; } Mail::fake(); $this->actingAs($user = User::factory()->withPersonalCompany()->create()); $component = Livewire::test(CompanyEmployeeManager::class, ['company' => $user->currentCompany]) ->set('addCompanyEmployeeForm', [ 'email' => 'test@example.com', 'role' => 'admin', ])->call('addCompanyEmployee'); Mail::assertSent(CompanyInvitation::class); $this->assertCount(1, $user->currentCompany->fresh()->companyInvitations); } public function test_company_employee_invitations_can_be_cancelled(): void { if (! Features::sendsCompanyInvitations()) { $this->markTestSkipped('Company invitations not enabled.'); return; } Mail::fake(); $this->actingAs($user = User::factory()->withPersonalCompany()->create()); // Add the company employee... $component = Livewire::test(CompanyEmployeeManager::class, ['company' => $user->currentCompany]) ->set('addCompanyEmployeeForm', [ 'email' => 'test@example.com', 'role' => 'admin', ])->call('addCompanyEmployee'); $invitationId = $user->currentCompany->fresh()->companyInvitations->first()->id; // Cancel the company invitation... $component->call('cancelCompanyInvitation', $invitationId); $this->assertCount(0, $user->currentCompany->fresh()->companyInvitations); } }