75 lines
2.6 KiB
PHP
75 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\Merchant;
|
|
use App\Models\Plan;
|
|
use App\Models\SiteSubscription;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Arr;
|
|
use Tests\TestCase;
|
|
|
|
class AdminSiteSubscriptionShowBroadNoReceiptOrdersLinkShouldUseSubscriptionShowSelfBackTest 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_broad_no_receipt_orders_link_should_use_subscription_show_self_as_back(): void
|
|
{
|
|
$this->loginAsPlatformAdmin();
|
|
|
|
$merchant = Merchant::query()->firstOrFail();
|
|
$plan = Plan::query()->create([
|
|
'code' => 'sub_show_broad_no_receipt_self_back_plan',
|
|
'name' => '订阅详情广义无回执回跳自环测试套餐',
|
|
'billing_cycle' => 'monthly',
|
|
'price' => 66,
|
|
'list_price' => 66,
|
|
'status' => 'active',
|
|
'sort' => 10,
|
|
'published_at' => now(),
|
|
]);
|
|
|
|
$subscription = SiteSubscription::query()->create([
|
|
'merchant_id' => $merchant->id,
|
|
'plan_id' => $plan->id,
|
|
'status' => 'active',
|
|
'source' => 'manual',
|
|
'subscription_no' => 'SS_SHOW_BNR_SELF_BACK_0001',
|
|
'plan_name' => $plan->name,
|
|
'billing_cycle' => $plan->billing_cycle,
|
|
'period_months' => 1,
|
|
'amount' => 66,
|
|
'starts_at' => now()->subDay(),
|
|
'ends_at' => now()->addMonth(),
|
|
]);
|
|
|
|
$res = $this->get('/admin/site-subscriptions/' . $subscription->id . '?back=' . urlencode('/admin/platform-orders?payment_status=paid'));
|
|
$res->assertOk();
|
|
|
|
$html = (string) $res->getContent();
|
|
$matched = preg_match('/无回执订单(广义):\s*<a[^>]+href="([^"]+)"/u', $html, $m);
|
|
$this->assertSame(1, $matched, '未找到订阅详情页“无回执订单(广义)”链接');
|
|
|
|
$href = html_entity_decode($m[1] ?? '');
|
|
$expectedUrl = '/admin/platform-orders?' . Arr::query([
|
|
'site_subscription_id' => $subscription->id,
|
|
'receipt_status' => 'none',
|
|
'back' => '/admin/site-subscriptions/' . $subscription->id,
|
|
]);
|
|
|
|
$this->assertSame($expectedUrl, $href);
|
|
$this->assertStringNotContainsString('payment_status=paid', $href);
|
|
$this->assertStringNotContainsString(urlencode('/admin/platform-orders?payment_status=paid'), $href);
|
|
}
|
|
}
|