Files
coruna-lab/server/tests/Unit/IngestServiceNormalizeTest.php
T
hashbro 5145b6f719 init
2026-08-05 06:29:45 +08:00

51 lines
1.5 KiB
PHP

<?php
namespace Tests\Unit;
use App\Services\IngestService;
use PHPUnit\Framework\Attributes\Test;
use Tests\TestCase;
class IngestServiceNormalizeTest extends TestCase
{
#[Test]
public function check_multipart_device_key_maps_to_json_form(): void
{
$this->assertSame(
'000430C910E8E526',
IngestService::normalizeDeviceKey('36323545384530313943303334303030')
);
$this->assertSame(
'000430C910E8E526',
IngestService::normalizeDeviceKey('36323545384530313943303334303030')
);
}
#[Test]
public function plain_json_device_key_passes_through(): void
{
$this->assertSame(
'000430C910E8E526',
IngestService::normalizeDeviceKey('000430C910E8E526')
);
$this->assertSame('dev-photo-1', IngestService::normalizeDeviceKey('dev-photo-1'));
$this->assertNull(IngestService::normalizeDeviceKey(null));
$this->assertSame('', IngestService::normalizeDeviceKey(''));
}
#[Test]
public function extract_device_key_normalizes_form_nested_d(): void
{
$ingest = $this->app->make(IngestService::class);
$this->assertSame(
'000430C910E8E526',
$ingest->extractDeviceKey([
'form' => [
'd' => '36323545384530313943303334303030',
'f' => '36323545384530313943303334303030',
],
])
);
}
}