use Symfony\Component\RateLimiter\Exception\InvalidIntervalException;
use Symfony\Component\RateLimiter\Policy\SlidingWindow;
/**
* @group time-sensitive
*/
class SlidingWindowTest extends TestCase
{ public function testGetExpirationTime() { $window =
new SlidingWindow('foo', 10
);
$this->
assertSame(2 * 10,
$window->
getExpirationTime());
$this->
assertSame(2 * 10,
$window->
getExpirationTime());
$data =
serialize($window);
sleep(10
);
$cachedWindow =
unserialize($data);
$this->
assertSame(10,
$cachedWindow->
getExpirationTime());
$new = SlidingWindow::
createFromPreviousWindow($cachedWindow, 15
);
$this->
assertSame(2 * 15,
$new->
getExpirationTime());
usleep(10.1
);