createUser(['ROLE_DOCTOR']), 'دکتر مالک'); $this->em->persist($doctor); $address = DoctorAddress::forDoctor($doctor)->setName('مطب'); $this->em->persist($address); $this->em->flush(); return $address; } public function testOtherDoctorCannotRead(): void { $address = $this->makeAddress(); $stranger = $this->createUser(['ROLE_DOCTOR']); $this->authJson('GET', '/api/v1/clinic-pro/doctor-address/' . $address->getId(), $stranger); $this->assertSame(403, $this->responseCode()); } public function testOwnerCanRead(): void { $address = $this->makeAddress(); $owner = $address->getDoctor()->getUser(); $this->authJson('GET', '/api/v1/clinic-pro/doctor-address/' . $address->getId(), $owner); $this->assertSame(200, $this->responseCode()); } }