23 lines
1.0 KiB
PHP
23 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Support\CourierBills\BillParser;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class BillParserColumnsTest extends TestCase
|
|
{
|
|
public function test_duplicate_amount_header_uses_the_last_column(): void
|
|
{
|
|
// 手工合并的账单:前面「运费」只有部分快递填了,最后一列「运费」才是含中转费、拦截费的最终金额
|
|
$columns = BillParser::findColumns(['快递单号', '发货时间', '快递名称1', '顺丰计费重量', '首重', '续重', '运费', '中转费', '拦截费', '运费']);
|
|
$this->assertSame(['waybill' => 0, 'amount' => 9, 'weight' => 3], array_intersect_key($columns, array_flip(['waybill', 'amount', 'weight'])));
|
|
}
|
|
|
|
public function test_single_amount_header_is_unchanged(): void
|
|
{
|
|
$this->assertSame(2, BillParser::findColumns(['运单号', '计费重量', '运费', '备注'])['amount']);
|
|
$this->assertSame(0, BillParser::findColumns(['运单号', '运费', '运单号'])['waybill']);
|
|
}
|
|
}
|