Files
saasshop/tests/Feature/AdminPlatformOrderIndexCompactViewGovernanceHintsStillReachableTest.php

102 lines
3.3 KiB
PHP

<?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 AdminPlatformOrderIndexCompactViewGovernanceHintsStillReachableTest 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_compact_view_still_shows_fix_links_for_reconcile_and_refund_inconsistent_orders(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'compact_view_governance_hints_test',
'name' => '精简视图治理入口测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$reconcileOrder = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_COMPACT_GOV_RECON_0001',
'order_type' => 'new_purchase',
'status' => 'activated',
'payment_status' => 'paid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 10,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'meta' => [
'payment_summary' => [
'count' => 1,
'total_amount' => 9.98,
],
],
]);
$refundOrder = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_COMPACT_GOV_REFUND_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' => 10,
'paid_amount' => 10,
'placed_at' => now(),
'paid_at' => now(),
'activated_at' => now(),
'refunded_at' => now(),
'meta' => [
'refund_summary' => [
'count' => 1,
'total_amount' => 9.98,
],
],
]);
// 默认即为精简视图:确保治理入口不依赖 col-optional 列依然可达
$backEncoded = rawurlencode('/admin/platform-orders');
$this->get('/admin/platform-orders')
->assertOk()
->assertSee('/admin/platform-orders/' . $reconcileOrder->id . '?back=' . $backEncoded . '#add-payment-receipt', false)
->assertSee('去补回执')
->assertSee('/admin/platform-orders/' . $refundOrder->id . '?back=' . $backEncoded . '#add-refund-receipt', false)
->assertSee('去核对退款');
}
}