61 lines
2.0 KiB
PHP
61 lines
2.0 KiB
PHP
<?php
|
||
|
||
namespace Tests\Feature;
|
||
|
||
use App\Models\Merchant;
|
||
use App\Models\PlatformOrder;
|
||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||
use Tests\TestCase;
|
||
|
||
class AdminPlatformOrderIndexRefundInconsistentFixLinkShouldPointToRefundSectionTest extends TestCase
|
||
{
|
||
use RefreshDatabase;
|
||
|
||
protected function loginAsPlatformAdmin(): void
|
||
{
|
||
$this->seed();
|
||
|
||
$this->post('/admin/login', [
|
||
'email' => 'platform.admin@demo.local',
|
||
'password' => 'Platform@123456',
|
||
])->assertRedirect('/admin');
|
||
}
|
||
|
||
public function test_index_refund_inconsistent_fix_link_should_point_to_refund_section(): void
|
||
{
|
||
$this->loginAsPlatformAdmin();
|
||
|
||
$merchant = Merchant::query()->firstOrFail();
|
||
|
||
// 构造:非 refunded,但 refund_total >= paid + tol(默认 tol=0.01) => isRefundInconsistent=true(注意要大于 paid)
|
||
$order = PlatformOrder::query()->create([
|
||
'merchant_id' => $merchant->id,
|
||
'plan_id' => null,
|
||
'site_subscription_id' => null,
|
||
'order_no' => 'PO_INDEX_REFUND_INCONSISTENT_FIX_LINK_2',
|
||
'order_type' => 'new_purchase',
|
||
'status' => 'pending',
|
||
'payment_status' => 'paid',
|
||
'payable_amount' => 10,
|
||
'paid_amount' => 10,
|
||
'paid_at' => now(),
|
||
'meta' => [
|
||
'refund_summary' => [
|
||
'total_amount' => 10.02,
|
||
'count' => 1,
|
||
],
|
||
],
|
||
]);
|
||
|
||
$res = $this->get('/admin/platform-orders?refund_inconsistent=1');
|
||
$res->assertOk();
|
||
|
||
$html = (string) $res->getContent();
|
||
|
||
// 退款不一致集合里,行内“去核对退款”应锚定到退款区块(#refund-receipts)。
|
||
$this->assertStringContainsString('疑似不一致', $html);
|
||
$this->assertStringContainsString('/admin/platform-orders/' . $order->id, $html);
|
||
$this->assertStringContainsString('#refund-receipts', $html);
|
||
}
|
||
}
|