39 lines
1.5 KiB
PHP
39 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Tests\Doctor;
|
|
|
|
use App\Doctor\Service\SourceProfileId;
|
|
use PHPUnit\Framework\Attributes\DataProvider;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* شناسهٔ پروفایل، کلید اصلی idempotency ایمپورت است؛ استخراجش باید در برابر تغییر
|
|
* قالب URL (دامنه/پارامتر اضافه) پایدار بماند و برای قالب ناشناخته null بدهد
|
|
* تا مسیر روی medical_system_code fallback کند.
|
|
*/
|
|
class SourceProfileIdTest extends TestCase
|
|
{
|
|
#[DataProvider('refs')]
|
|
public function testFromRef(?string $ref, ?string $expected): void
|
|
{
|
|
$this->assertSame($expected, SourceProfileId::fromRef($ref));
|
|
}
|
|
|
|
public static function refs(): array
|
|
{
|
|
$uuid = 'ad600622-b98a-48ac-a448-89ef68fd2c46';
|
|
|
|
return [
|
|
'irimc profile url' => ["https://membersearch.irimc.org/member/profile?id=$uuid", $uuid],
|
|
'extra query params' => ["https://membersearch.irimc.org/member/profile?lang=fa&id=$uuid&x=1", $uuid],
|
|
'different host, same id' => ["http://example.test/x?id=$uuid", $uuid],
|
|
'uppercase normalized to lowercase' => ['?id=' . strtoupper($uuid), $uuid],
|
|
'no id param' => ['https://membersearch.irimc.org/member/profile', null],
|
|
'plain code, not a url' => ['42507', null],
|
|
'empty' => ['', null],
|
|
'whitespace' => [' ', null],
|
|
'null' => [null, null],
|
|
];
|
|
}
|
|
}
|