fix(clinic): send each contracted insurer's logo to the public page

The clinic payload carried only uuid/id/name for list_bime, so the public
page fell back to the same placeholder for every insurer and the section
read as broken. The logo has been on the insurance record all along.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
hamed
2026-08-19 23:33:34 +03:30
co-authored by Claude Opus 5
parent e4bd37b3bd
commit b33f38072d
3 changed files with 67 additions and 1 deletions
+60
View File
@@ -0,0 +1,60 @@
<?php
namespace App\Tests\Clinic;
use App\Clinic\Entity\Clinic;
use App\Insurance\Entity\Insurance;
use App\Insurance\Enum\InsuranceType;
use App\Tests\ApiTestCase;
/**
* The public clinic page renders each contracted insurer with its logo. The
* payload carried only uuid/id/name, so every insurer fell back to the same
* placeholder and the section looked broken.
*/
class ClinicInsuranceLogoTest extends ApiTestCase
{
private const LOGO = '/uploads/insurances/logo/2026-08/tamin.png';
private function makeClinicWithInsurances(): Clinic
{
$withLogo = new Insurance('بیمه لوگودار ' . random_int(1000, 9999), InsuranceType::Basic);
$withLogo->setLogoUrl(self::LOGO);
$this->em->persist($withLogo);
$withoutLogo = new Insurance('بیمه بی‌لوگو ' . random_int(1000, 9999), InsuranceType::Basic);
$this->em->persist($withoutLogo);
$clinic = new Clinic($this->createUser(['ROLE_USER', 'ROLE_CLINIC']));
$clinic->setName('کلینیک تست بیمه');
$clinic->getInsurances()->add($withLogo);
$clinic->getInsurances()->add($withoutLogo);
$this->em->persist($clinic);
$this->em->flush();
return $clinic;
}
public function testClinicPayloadCarriesEachInsurerLogo(): void
{
$clinic = $this->makeClinicWithInsurances();
$list = $clinic->toDetailArray()['list_bime'];
$urls = array_column($list, 'logo_url', 'name');
self::assertCount(2, $list);
self::assertContains(self::LOGO, $urls);
self::assertContains(null, $urls, 'بیمهٔ بدون لوگو باید null بدهد، نه کلید غایب');
}
public function testPublicClinicEndpointExposesTheLogo(): void
{
$clinic = $this->makeClinicWithInsurances();
$this->client->request('GET', '/api/v1/clinic/' . $clinic->getUuid());
$body = json_decode($this->client->getResponse()->getContent(), true);
$payload = $body['data']['data'] ?? $body['data'];
self::assertContains(self::LOGO, array_column($payload['list_bime'], 'logo_url'));
}
}