createUser(['ROLE_DOCTOR']), 'دکتر'); $this->em->persist($doctor); $this->em->flush(); return $doctor; } /** @return iterable */ public static function endpoints(): iterable { yield 'date-override list' => ['/api/v1/appointment-settings/date-override/list/']; yield 'holidays list' => ['/api/v1/appointment-settings/holidays/list/']; yield 'available-locations' => ['/api/v1/appointment-settings/available-locations/']; } #[DataProvider('endpoints')] public function testStrangerForbidden(string $prefix): void { $doctor = $this->makeDoctor(); $stranger = $this->createUser(['ROLE_DOCTOR']); $this->authJson('GET', $prefix . $doctor->getUuid(), $stranger); $this->assertSame(403, $this->responseCode()); } #[DataProvider('endpoints')] public function testOwnerAllowed(string $prefix): void { $doctor = $this->makeDoctor(); $this->authJson('GET', $prefix . $doctor->getUuid(), $doctor->getUser()); $this->assertSame(200, $this->responseCode()); } }