Files
saasshop/tests/Feature/AdminPlatformOrderIndexLeadLockGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest.php

53 lines
2.0 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 Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformOrderIndexLeadLockGovernanceLinksShouldIncludeRenewalMissingSubscriptionTest 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_lead_lock_governance_links_should_include_renewal_missing_subscription(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin/platform-orders?lead_id=12&merchant_id=2&plan_id=3&site_subscription_id=4&back=%2Fadmin%2Fplans&syncable_only=1');
$res->assertOk();
$html = (string) $res->getContent();
// 线索治理入口:应出现“查看续费缺订阅(该线索)”
$matched = preg_match('/<a[^>]+href="([^"]+)"[^>]*>\s*查看续费缺订阅(该线索)\s*<\/a>/u', $html, $m);
$this->assertSame(1, $matched, '未找到线索治理入口:查看续费缺订阅(该线索)');
$url = $m[1] ?? '';
$parts = parse_url($url);
parse_str($parts['query'] ?? '', $q);
// 应保留上下文lead/merchant/plan/subscription/back并覆盖 renewal_missing_subscription
$this->assertSame('12', (string) ($q['lead_id'] ?? ''));
$this->assertSame('2', (string) ($q['merchant_id'] ?? ''));
$this->assertSame('3', (string) ($q['plan_id'] ?? ''));
$this->assertSame('4', (string) ($q['site_subscription_id'] ?? ''));
$this->assertSame('/admin/plans', (string) ($q['back'] ?? ''));
$this->assertSame('1', (string) ($q['renewal_missing_subscription'] ?? ''));
// 不应继承工具型开关
$this->assertArrayNotHasKey('syncable_only', $q);
$this->assertArrayNotHasKey('page', $q);
}
}