createClinic('یزد، خیابان قدیمی', '03531234567'); $this->createAddressFor($clinic, 'کرج، بلوار طالقانی', '02634567890'); $data = $this->fetchClinic($clinic); $this->assertSame('کرج، بلوار طالقانی', $data['location']); $this->assertSame('02634567890', $data['phone']); $this->assertSame('02634567890', $data['phone_number']); $this->assertSame('کرج', $data['city'][0]['name'] ?? null); $this->assertSame('البرز', $data['state'][0]['name'] ?? null); } public function testLegacyColumnsAreUsedWhenTheClinicHasNoAddressRecord(): void { $clinic = $this->createClinic('یزد، خیابان قدیمی', '03531234567'); $data = $this->fetchClinic($clinic); $this->assertSame('یزد، خیابان قدیمی', $data['location']); $this->assertSame('03531234567', $data['phone']); $this->assertSame([], $data['city']); } public function testBlankAddressFieldsFallBackInsteadOfBlankingTheContactBlock(): void { $clinic = $this->createClinic('یزد، خیابان قدیمی', '03531234567'); $this->createAddressFor($clinic, ' ', null); $data = $this->fetchClinic($clinic); $this->assertSame('یزد، خیابان قدیمی', $data['location']); $this->assertSame('03531234567', $data['phone']); $this->assertSame('کرج', $data['city'][0]['name'] ?? null); } private function createClinic(?string $legacyAddress, ?string $legacyPhone): Clinic { $clinic = new Clinic($this->createUser(['ROLE_CLINIC'])); $clinic->setName('کلینیک تست تماس'); $clinic->setAddress($legacyAddress); $clinic->setTelephone($legacyPhone); $this->em->persist($clinic); $this->em->flush(); return $clinic; } private function createAddressFor(Clinic $clinic, ?string $street, ?string $phone): DoctorAddress { $province = new Province('البرز'); $city = new City('کرج', $province); $this->em->persist($province); $this->em->persist($city); $address = DoctorAddress::forClinic((int) $clinic->getId()); $address->setAddress($street); $address->setTelephone($phone); $address->setCity($city); $address->setProvince($province); $this->em->persist($address); $this->em->flush(); return $address; } private function fetchClinic(Clinic $clinic): array { $this->client->request('GET', '/api/v1/clinic/' . $clinic->getUuid()); $this->assertSame(200, $this->responseCode()); return json_decode($this->client->getResponse()->getContent(), true)['data']['data']; } }