Files
saasshop/tests/Feature/AdminPlatformOrderShowRefundInconsistentHintLinkTest.php

73 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Tests\Feature;
use App\Models\Merchant;
use App\Models\Plan;
use App\Models\PlatformOrder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderShowRefundInconsistentHintLinkTest 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_show_page_will_show_refund_inconsistent_hint_and_link(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'refund_inconsistent_show_hint_01',
'name' => '退款不一致详情提示测试',
'billing_cycle' => 'monthly',
'price' => 30,
'list_price' => 30,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
// 不一致refunded 但退款总额不足
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_REFUND_INCONS_SHOW_0001',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'refunded',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 30,
'paid_amount' => 30,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'refunded_at' => now(),
'meta' => [
'refund_summary' => [
'count' => 1,
'total_amount' => 10,
],
],
]);
$this->get('/admin/platform-orders/' . $order->id)
->assertOk()
->assertSee('疑似存在「退款状态 vs 退款总额」不一致')
->assertSee('/admin/platform-orders?refund_inconsistent=1');
}
}