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>
61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?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'));
|
|
}
|
|
}
|