Files
saasshop/tests/Feature/AdminPlatformOrderShowAuditActionLabelsShouldRenderMoreActionsTest.php

82 lines
2.6 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 AdminPlatformOrderShowAuditActionLabelsShouldRenderMoreActionsTest 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_should_render_action_labels_for_batch_bmpa_and_attach_subscription(): void
{
$this->loginAsPlatformAdmin();
$merchant = Merchant::query()->firstOrFail();
$plan = Plan::query()->create([
'code' => 'audit_action_labels_more_plan',
'name' => '审计动作名补齐测试套餐',
'billing_cycle' => 'monthly',
'price' => 30,
'list_price' => 30,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$order = PlatformOrder::query()->create([
'merchant_id' => $merchant->id,
'plan_id' => $plan->id,
'order_no' => 'PO_AUDIT_ACTION_LABELS_MORE_0001',
'order_type' => 'renewal',
'status' => 'pending',
'payment_status' => 'unpaid',
'plan_name' => $plan->name,
'billing_cycle' => $plan->billing_cycle,
'period_months' => 1,
'quantity' => 1,
'payable_amount' => 30,
'paid_amount' => 0,
'placed_at' => now(),
'meta' => [
'audit' => [
[
'action' => 'attach_subscription',
'scope' => 'single',
'at' => now()->toDateTimeString(),
'admin_id' => 1,
'subscription_id' => 123,
'note' => '测试',
],
[
'action' => 'batch_mark_paid_and_activate',
'scope' => 'filtered',
'at' => now()->toDateTimeString(),
'admin_id' => 1,
'note' => '测试',
],
],
],
]);
$this->get('/admin/platform-orders/' . $order->id)
->assertOk()
->assertSee('绑定订阅(续费缺订阅治理)')
->assertSee('批量标记支付并生效BMPA');
}
}