Files
saasshop/tests/Feature/AdminPlatformLeadIndexShouldIncludeRenewalMissingSubscriptionGovernanceLinkTest.php

62 lines
2.0 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\Plan;
use App\Models\PlatformLead;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformLeadIndexShouldIncludeRenewalMissingSubscriptionGovernanceLinkTest 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_lead_index_should_include_renewal_missing_subscription_governance_link(): void
{
$this->loginAsPlatformAdmin();
$plan = Plan::query()->create([
'code' => 'lead_index_rms_link_plan',
'name' => '线索页续费缺订阅治理入口测试套餐',
'billing_cycle' => 'monthly',
'price' => 10,
'list_price' => 10,
'status' => 'active',
'sort' => 10,
'published_at' => now(),
]);
$lead = PlatformLead::query()->create([
'status' => 'new',
'name' => '张三',
'mobile' => '13800000000',
'email' => 'zs@example.com',
'company' => '测试公司',
'plan_id' => $plan->id,
'source' => 'test',
'meta' => [],
]);
$res = $this->get('/admin/platform-leads');
$res->assertOk();
$html = (string) $res->getContent();
// 应出现“续费缺订阅”按钮,并携带 lead_id + renewal_missing_subscription=1 + back 回线索页
$this->assertStringContainsString('续费缺订阅', $html);
$this->assertStringContainsString('/admin/platform-orders?lead_id=' . $lead->id, $html);
$this->assertStringContainsString('renewal_missing_subscription=1', $html);
$this->assertStringContainsString('back=' . urlencode('/admin/platform-leads'), $html);
}
}