resolver(jobProfiles: [5 => $jobProfile]); $this->assertSame($jobProfile, $resolver->jobProfile(StaffingRole::GUIDE)); } public function testAnUnconfiguredRoleIsRefused(): void { $this->expectException(StaffingConfigurationException::class); $this->expectExceptionMessage('auto_assignment_job_profiles.ski_beginner'); $this->resolver()->jobProfile(StaffingRole::SKI_BEGINNER); } public function testADeletedJobProfileIsRefused(): void { $this->expectException(StaffingConfigurationException::class); $this->resolver(jobProfiles: [5 => (new JobProfile())->setDeleted()])->jobProfile(StaffingRole::GUIDE); } public function testAMissingFeeIsRefused(): void { $this->expectException(StaffingConfigurationException::class); $this->expectExceptionMessage('auto_assignment_fees.course'); $this->resolver(fees: [3 => new Fee()])->fee(StaffingFee::COURSE); } public function testAssertConfiguredChecksEveryRoleAndFee(): void { $jobProfiles = []; foreach ([5, 3, 14, 20] as $id) { $jobProfiles[$id] = new JobProfile(); } // guide_ski_advanced (21) is missing $this->expectException(StaffingConfigurationException::class); $this->expectExceptionMessage('guide_ski_advanced'); $this->resolver(jobProfiles: $jobProfiles, fees: [3 => new Fee(), 4 => new Fee()])->assertConfigured(); } /** * @param array $jobProfiles * @param array $fees */ private function resolver(array $jobProfiles = [], array $fees = []): StaffingResolver { $jobProfileRepository = $this->createStub(JobProfileRepository::class); $jobProfileRepository->method('find')->willReturnCallback(static fn ($id) => $jobProfiles[$id] ?? null); $feeRepository = $this->createStub(FeeRepository::class); $feeRepository->method('find')->willReturnCallback(static fn ($id) => $fees[$id] ?? null); return new StaffingResolver( $jobProfileRepository, $feeRepository, ['guide' => 5, 'ski_beginner' => 3, 'ski_advanced' => 14, 'guide_ski_beginner' => 20, 'guide_ski_advanced' => 21], ['guiding' => 3, 'course' => 4], ); } }