Files
saasshop/tests/Feature/AdminPlatformOrderBmpaFailedReasonLongDoesNotRenderKeywordLinkTest.php

76 lines
2.5 KiB
PHP
Raw Permalink 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 AdminPlatformOrderBmpaFailedReasonLongDoesNotRenderKeywordLinkTest 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_platform_orders_page_long_bmpa_reason_should_not_render_keyword_link(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'bmpa_reason_long_guard_plan',
'name' => 'BMPA失败原因过长链接护栏测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
// 需要超过页面阈值(默认 config 为 200这里用 260 触发“原因过长”分支
$longReason = str_repeat('错', 260);
PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_BMPA_LONG_REASON_0001',
'order_type' => 'new_purchase',
'status' => 'pending',
'payment_status' => 'unpaid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 10,
'paid_amount' => 0,
'placed_at' => now(),
'meta' => [
'batch_mark_paid_and_activate_error' => [
'message' => $longReason,
'at' => now()->toDateTimeString(),
'admin_id' => 1,
],
],
]);
$res = $this->get('/admin/platform-orders');
$res->assertOk();
// 原因过长时应出现提示,但不生成包含 bmpa_error_keyword 的链接
$res->assertSee('批量标记支付并生效失败原因 TOP5');
$res->assertSee('原因过长,请复制到筛选框', false);
$res->assertDontSee('bmpa_error_keyword=' . urlencode($longReason), false);
}
}