补齐待支付/待生效快捷筛选保留上下文且清理工具开关护栏测试
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformOrderIndexQuickFiltersUnpaidAndPendingEffectiveShouldPreserveContextTest 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_unpaid_and_pending_effective_quick_filters_should_preserve_context_and_clear_toggles(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$res = $this->get('/admin/platform-orders?merchant_id=1'
|
||||
. '&created_from=2026-03-01&created_to=2026-03-18'
|
||||
. '&page=2'
|
||||
. '&bmpa_failed_only=1&bmpa_error_keyword=timeout&fail_only=1'
|
||||
. '&back=/admin'
|
||||
);
|
||||
$res->assertOk();
|
||||
|
||||
$html = (string) $res->getContent();
|
||||
|
||||
// 1) 待支付
|
||||
$this->assertMatchesRegularExpression('/<a[^>]*data-role="po-quickfilter-unpaid"[^>]*href="([^"]+)"/u', $html);
|
||||
preg_match('/<a[^>]*data-role="po-quickfilter-unpaid"[^>]*href="([^"]+)"/u', $html, $m1);
|
||||
$href1 = html_entity_decode($m1[1] ?? '');
|
||||
$query1 = parse_url($href1, PHP_URL_QUERY) ?: '';
|
||||
parse_str($query1, $q1);
|
||||
|
||||
$this->assertSame('unpaid', (string) ($q1['payment_status'] ?? ''));
|
||||
|
||||
$this->assertSame('1', (string) ($q1['merchant_id'] ?? ''));
|
||||
$this->assertSame('2026-03-01', (string) ($q1['created_from'] ?? ''));
|
||||
$this->assertSame('2026-03-18', (string) ($q1['created_to'] ?? ''));
|
||||
$this->assertSame('/admin', (string) ($q1['back'] ?? ''));
|
||||
|
||||
$this->assertArrayNotHasKey('page', $q1);
|
||||
$this->assertArrayNotHasKey('bmpa_failed_only', $q1);
|
||||
$this->assertArrayNotHasKey('bmpa_error_keyword', $q1);
|
||||
$this->assertArrayNotHasKey('fail_only', $q1);
|
||||
|
||||
// 2) 待生效
|
||||
$this->assertMatchesRegularExpression('/<a[^>]*data-role="po-quickfilter-pending-effective"[^>]*href="([^"]+)"/u', $html);
|
||||
preg_match('/<a[^>]*data-role="po-quickfilter-pending-effective"[^>]*href="([^"]+)"/u', $html, $m2);
|
||||
$href2 = html_entity_decode($m2[1] ?? '');
|
||||
$query2 = parse_url($href2, PHP_URL_QUERY) ?: '';
|
||||
parse_str($query2, $q2);
|
||||
|
||||
$this->assertSame('paid', (string) ($q2['payment_status'] ?? ''));
|
||||
$this->assertSame('pending', (string) ($q2['status'] ?? ''));
|
||||
$this->assertSame('unsynced', (string) ($q2['sync_status'] ?? ''));
|
||||
|
||||
$this->assertSame('1', (string) ($q2['merchant_id'] ?? ''));
|
||||
$this->assertSame('2026-03-01', (string) ($q2['created_from'] ?? ''));
|
||||
$this->assertSame('2026-03-18', (string) ($q2['created_to'] ?? ''));
|
||||
$this->assertSame('/admin', (string) ($q2['back'] ?? ''));
|
||||
|
||||
$this->assertArrayNotHasKey('page', $q2);
|
||||
$this->assertArrayNotHasKey('bmpa_failed_only', $q2);
|
||||
$this->assertArrayNotHasKey('bmpa_error_keyword', $q2);
|
||||
$this->assertArrayNotHasKey('fail_only', $q2);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user