createUser(['ROLE_DOCTOR']); $doctor = new Doctor($owner, 'دکتر تست'); $this->em->persist($doctor); $schedule = new WeeklySchedule($doctor, ['sat' => []]); $this->em->persist($schedule); $this->em->flush(); return [$owner, $doctor]; } public function testOwnerCanReadOwnSchedule(): void { [$owner, $doctor] = $this->makeDoctorWithSchedule(); $this->authJson('GET', '/api/v1/appointment-settings/weekly-schedule/' . $doctor->getUuid(), $owner); $this->assertSame(200, $this->responseCode()); } public function testOtherUserIsForbidden(): void { [, $doctor] = $this->makeDoctorWithSchedule(); $attacker = $this->createUser(['ROLE_DOCTOR']); $this->authJson('GET', '/api/v1/appointment-settings/weekly-schedule/' . $doctor->getUuid(), $attacker); $this->assertSame(403, $this->responseCode()); } public function testAdminCanRead(): void { [, $doctor] = $this->makeDoctorWithSchedule(); $admin = $this->createUser(['ROLE_ADMIN']); $this->authJson('GET', '/api/v1/appointment-settings/weekly-schedule/' . $doctor->getUuid(), $admin); $this->assertSame(200, $this->responseCode()); } }