createUser(['ROLE_DOCTOR']); $doctor = new Doctor($owner, 'دکتر تست'); $this->em->persist($doctor); $this->em->flush(); return [$owner, $doctor]; } public function testNationalCodeFromProfileIsReturned(): void { [$owner, $doctor] = $this->doctor(); $patient = $this->createUser(['ROLE_USER']); // کد ملی فقط روی پروفایل، نه روی خود کاربر $profile = new UserProfile($patient); $profile->setNationalCode('0012345675'); $this->em->persist($profile); $record = new PatientRecord('doctor', $doctor->getId(), $patient, 'doctor', $doctor->getId()); $this->em->persist($record); $this->em->flush(); $res = $this->authJson('GET', '/api/v1/patients', $owner); self::assertSame(200, $this->responseCode()); self::assertSame($record->getUuid(), $res['data'][0]['uuid']); self::assertSame('0012345675', $res['data'][0]['user_national_code']); } public function testNullWhenNoNationalCodeAnywhere(): void { [$owner, $doctor] = $this->doctor(); $patient = $this->createUser(['ROLE_USER']); $record = new PatientRecord('doctor', $doctor->getId(), $patient, 'doctor', $doctor->getId()); $this->em->persist($record); $this->em->flush(); $res = $this->authJson('GET', '/api/v1/patients', $owner); self::assertSame(200, $this->responseCode()); self::assertNull($res['data'][0]['user_national_code']); } }