e393b11b61
补齐节点管理真实新增、编辑与排序流程,接入权限组与路由组 维护页,并支持 11 种协议的动态配置表单 开放礼品卡管理入口,交付模板、兑换码、使用记录与统计四页签 工作台,接入 gift-card 相关后台接口 将知识库、权限组与路由管理从占位页升级为真实页面,并修复侧边栏 低高度裁切问题 修复仪表盘 24h 流量排行涨跌始终为 0 的问题,改为对比昨天整日统 计并补充单元测试
48 lines
1.5 KiB
PHP
48 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Tests\Unit\Admin;
|
|
|
|
use App\Http\Controllers\V2\Admin\StatController;
|
|
use PHPUnit\Framework\TestCase;
|
|
use ReflectionMethod;
|
|
|
|
class StatControllerTrafficRankWindowTest extends TestCase
|
|
{
|
|
public function test_single_day_rank_window_compares_with_exact_previous_day(): void
|
|
{
|
|
$startDate = strtotime('2026-04-24 00:00:00');
|
|
$endDate = strtotime('2026-04-24 23:59:59');
|
|
|
|
$comparisonWindow = $this->resolveWindow($startDate, $endDate);
|
|
|
|
$this->assertSame(strtotime('2026-04-23 00:00:00'), $comparisonWindow['start']);
|
|
$this->assertSame($startDate, $comparisonWindow['end']);
|
|
}
|
|
|
|
public function test_multi_day_rank_window_keeps_existing_equal_span_behavior(): void
|
|
{
|
|
$startDate = strtotime('2026-04-18 00:00:00');
|
|
$endDate = strtotime('2026-04-24 23:59:59');
|
|
|
|
$comparisonWindow = $this->resolveWindow($startDate, $endDate);
|
|
|
|
$this->assertSame($startDate - ($endDate - $startDate), $comparisonWindow['start']);
|
|
$this->assertSame($startDate, $comparisonWindow['end']);
|
|
}
|
|
|
|
/**
|
|
* @return array{start: int, end: int}
|
|
*/
|
|
private function resolveWindow(int $startDate, int $endDate): array
|
|
{
|
|
$controller = new StatController();
|
|
$method = new ReflectionMethod(StatController::class, 'resolveTrafficRankComparisonWindow');
|
|
$method->setAccessible(true);
|
|
|
|
/** @var array{start: int, end: int} $result */
|
|
$result = $method->invoke($controller, $startDate, $endDate);
|
|
|
|
return $result;
|
|
}
|
|
}
|