- 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.
54 lines
2.5 KiB
PHP
54 lines
2.5 KiB
PHP
<?php
|
||
|
||
namespace App\Tests\Shared;
|
||
|
||
use App\Shared\Util\PersianText;
|
||
use PHPUnit\Framework\TestCase;
|
||
|
||
class PersianTextTest extends TestCase
|
||
{
|
||
public function testArabicYehAndKafAreUnified(): void
|
||
{
|
||
$this->assertTrue(PersianText::sameName("علي اكبري", 'علی اکبری'));
|
||
}
|
||
|
||
public function testHalfSpaceAndExtraWhitespace(): void
|
||
{
|
||
$this->assertTrue(PersianText::sameName("محمد\u{200C}رضا کریمی ", 'محمد رضا کریمی'));
|
||
}
|
||
|
||
public function testPersianAndArabicDigits(): void
|
||
{
|
||
$this->assertSame('1371/1/1', PersianText::normalize('۱۳۷۱/۱/۱'));
|
||
$this->assertSame('0912', PersianText::normalize('٠٩١٢'));
|
||
}
|
||
|
||
public function testStripDoctorTitle(): void
|
||
{
|
||
$this->assertSame('فرخنده حسینی', PersianText::stripDoctorTitle('دکتر فرخنده حسینی'));
|
||
$this->assertSame('فرخنده حسینی', PersianText::stripDoctorTitle(' دکتر فرخنده حسینی '));
|
||
$this->assertSame('فرخنده حسینی', PersianText::stripDoctorTitle('فرخنده حسینی'));
|
||
$this->assertSame('صفورا حجازی نیا', PersianText::stripDoctorTitle('دکتر صفورا حجازی نیا'));
|
||
// پیشوند متوالی و کافِ عربی
|
||
$this->assertSame('صفورا حجازی نیا', PersianText::stripDoctorTitle('دکتر دکتر صفورا حجازی نیا'));
|
||
$this->assertSame('علی اکبری', PersianText::stripDoctorTitle('دكتر علي اكبري'));
|
||
}
|
||
|
||
public function testDifferentNamesStayDifferent(): void
|
||
{
|
||
$this->assertFalse(PersianText::sameName('علی اکبری', 'ولی اکبری'));
|
||
}
|
||
|
||
public function testWithDoctorTitlePrependsExactlyOnce(): void
|
||
{
|
||
$this->assertSame('دکتر فرخنده حسینی', PersianText::withDoctorTitle('فرخنده حسینی'));
|
||
// نامِ از پیش عنواندار «دکتر دکتر …» نمیشود
|
||
$this->assertSame('دکتر فرخنده حسینی', PersianText::withDoctorTitle('دکتر فرخنده حسینی'));
|
||
$this->assertSame('دکتر فرخنده حسینی', PersianText::withDoctorTitle('دکتر دکتر فرخنده حسینی'));
|
||
// خالی/نال → رشتهٔ خالی (نه «دکتر» تنها)
|
||
$this->assertSame('', PersianText::withDoctorTitle(''));
|
||
$this->assertSame('', PersianText::withDoctorTitle(null));
|
||
$this->assertSame('', PersianText::withDoctorTitle(' '));
|
||
}
|
||
}
|