Skip to content

Commit f8c2245

Browse files
committed
test: fix time dependent test
Fixes #5444
1 parent f7c4226 commit f8c2245

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

tests/system/Throttle/ThrottleTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@ public function testOverload()
127127

128128
public function testFlooding()
129129
{
130+
$time = 1639441295;
131+
130132
$throttler = new Throttler($this->cache);
133+
$throttler->setTestTime($time);
131134

132135
$rate = 60; // allow 1 per second after the bucket is emptied
133136
$cost = 1;
@@ -141,7 +144,7 @@ public function testFlooding()
141144
$this->assertFalse($throttler->check('127.0.0.1', $rate, MINUTE, $cost));
142145
$this->assertSame(0, $this->cache->get('throttler_127.0.0.1'));
143146

144-
$throttler = $throttler->setTestTime(strtotime('+10 seconds'));
147+
$throttler = $throttler->setTestTime($time + 10);
145148

146149
$this->assertTrue($throttler->check('127.0.0.1', $rate, MINUTE, 0));
147150
$this->assertSame(10.0, round($this->cache->get('throttler_127.0.0.1')));

0 commit comments

Comments
 (0)