PlatformOrder: add orderTypeLabel helper

This commit is contained in:
萝卜
2026-03-15 01:40:09 +00:00
parent 2ad5b49096
commit c81c5a1f39
2 changed files with 48 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
<?php
namespace Tests\Unit;
use App\Models\PlatformOrder;
use Tests\TestCase;
class PlatformOrderOrderTypeLabelTest extends TestCase
{
public function test_order_type_label_should_map_known_types(): void
{
$o = new PlatformOrder();
$o->order_type = 'new_purchase';
$this->assertSame('新购', $o->orderTypeLabel());
$o->order_type = 'renewal';
$this->assertSame('续费', $o->orderTypeLabel());
$o->order_type = 'upgrade';
$this->assertSame('升级', $o->orderTypeLabel());
$o->order_type = 'downgrade';
$this->assertSame('降级', $o->orderTypeLabel());
}
public function test_order_type_label_should_fallback_to_code_when_unknown(): void
{
$o = new PlatformOrder();
$o->order_type = 'something_new';
$this->assertSame('something_new', $o->orderTypeLabel());
}
}