Files
saasshop/tests/Feature/AdminDashboardPlatformOrderTrend7dCardShouldRenderRowsTest.php

39 lines
1.1 KiB
PHP
Raw Permalink 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 AdminDashboardPlatformOrderTrend7dCardShouldRenderRowsTest 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_dashboard_platform_order_trend_7d_card_should_render_rows(): void
{
$this->loginAsPlatformAdmin();
$res = $this->get('/admin');
$res->assertOk();
// 趋势卡近7天应存在并渲染 7 天的行(即使当天无数据也补 0
$res->assertSee('data-role="platform-order-trend-7d"', false);
$html = (string) $res->getContent();
// 粗略计数tbody 内应出现 7 次日期文本YYYY-MM-DD
preg_match_all('/\d{4}-\d{2}-\d{2}/', $html, $m);
$this->assertGreaterThanOrEqual(7, count($m[0] ?? []));
}
}