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(); // db_test ریست نمی‌شود؛ کد ملیِ یکتا رندوم تا با اجراهای قبلی تصادم نکند. $nc = '00' . str_pad((string) random_int(0, 99_999_999), 8, '0', STR_PAD_LEFT); $patient = $this->createUser(['ROLE_USER']); // کد ملی فقط روی پروفایل، نه روی خود کاربر $profile = new UserProfile($patient); $profile->setNationalCode($nc); $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($nc, $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']); } }