Files
clinicpro/tests/Auth/PreRegistrationNameTitleTest.php
T
hamed 74577c2ff6 feat: unify doctor title handling and enhance specialty selection
- Implemented a helper function `displayDoctorName` to prepend "دکتر" to doctor names for consistent display across the application.
- Updated various components (InviteDoctorModal, DashboardPage, DoctorDetailPage, DoctorsPage, etc.) to utilize the new helper for rendering doctor names.
- Modified the DoctorFormPage to automatically add the "دکتر" title in the UI without requiring user input.
- Fixed the EditSpecialtyPicker component to allow multiple specialty selections, resolving a UI bug where only one specialty could be selected at a time.
- Ensured that the backend strips the "دکتر" title from the name during pre-registration and doctor creation processes.
- Added tests for the new functionality, including checks for title handling and specialty selection logic.
- Updated API documentation to reflect changes in name handling and display logic.
2026-07-19 19:57:03 +03:30

67 lines
2.2 KiB
PHP

<?php
namespace App\Tests\Auth;
use App\Auth\Entity\PreRegistration;
use App\Tests\ApiTestCase;
/**
* نام ثبت‌شده در پیش‌ثبت‌نام هرگز نباید عنوان «دکتر» را در خود نگه دارد — وگرنه پس از
* تأیید، پزشک/کلینیک/realName ساخته‌شده «دکتر دکتر …» نمایش داده می‌شوند. عنوان فقط در
* لایهٔ نمایش افزوده می‌شود (displayDoctorName سمت فرانت).
*/
class PreRegistrationNameTitleTest extends ApiTestCase
{
private function freshMobile(): string
{
return '09' . str_pad((string) random_int(0, 999_999_999), 9, '0', STR_PAD_LEFT);
}
private function submit(string $name, string $mobile): array
{
$this->client->request(
'POST',
'/api/v1/pre-registration',
server: ['CONTENT_TYPE' => 'application/json'],
content: json_encode(['type' => 'independent_doctor', 'name' => $name, 'mobile' => $mobile]),
);
return json_decode($this->client->getResponse()->getContent(), true) ?? [];
}
private function storedName(string $mobile): ?string
{
$this->em->clear();
$preReg = $this->em->getRepository(PreRegistration::class)->findOneBy(['mobile' => $mobile]);
return $preReg?->getName();
}
public function testTitleIsStrippedOnSubmit(): void
{
$mobile = $this->freshMobile();
$this->submit('دکتر حامد حسینی', $mobile);
self::assertSame(201, $this->responseCode());
self::assertSame('حامد حسینی', $this->storedName($mobile));
}
public function testPlainNameIsLeftAlone(): void
{
$mobile = $this->freshMobile();
$this->submit('حامد حسینی', $mobile);
self::assertSame(201, $this->responseCode());
self::assertSame('حامد حسینی', $this->storedName($mobile));
}
public function testRepeatedTitlePrefixIsCollapsed(): void
{
$mobile = $this->freshMobile();
$this->submit('دکتر دکتر حامد حسینی', $mobile);
self::assertSame(201, $this->responseCode());
self::assertSame('حامد حسینی', $this->storedName($mobile));
}
}