Files
ECShopX/tests/ShuyunOpenPlatform/HistoricalSyncRateLimiterTest.php
wanghai 058673559c 4.7.0
2026-06-26 19:20:24 +08:00

22 lines
575 B
PHP

<?php
declare(strict_types=1);
namespace Tests\ShuyunOpenPlatform;
use ShuyunOpenPlatformBundle\Services\HistoricalSync\HistoricalSyncRateLimiter;
class HistoricalSyncRateLimiterTest extends \TestCase
{
public function testOneQpsSpansAtLeastTwoSecondsForThreeCalls(): void
{
$limiter = new HistoricalSyncRateLimiter(1.0);
$start = microtime(true);
$limiter->throttle();
$limiter->throttle();
$limiter->throttle();
$elapsed = microtime(true) - $start;
$this->assertGreaterThanOrEqual(1.9, $elapsed);
}
}