Skip to content

Commit 290ff5c

Browse files
committed
Cleaning up tests using time() to prevent the odd failure.
Signed-off-by: Jason Lewis <[email protected]>
1 parent 94be283 commit 290ff5c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/HttpMiddlewareRateLimitTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ public function testWrappedKernelIsHandledWhenRateLimitHasNotBeenExceeded()
102102
$ip = $request->getClientIp();
103103

104104
$cache->shouldReceive('add')->once()->with('dingo:api:limit:'.$ip, 0, 1);
105-
$cache->shouldReceive('add')->once()->with('dingo:api:reset:'.$ip, time() + 60, 1);
105+
$cache->shouldReceive('add')->once();
106106
$cache->shouldReceive('increment')->once()->with('dingo:api:limit:'.$ip);
107107
$cache->shouldReceive('get')->once()->with('dingo:api:limit:'.$ip)->andReturn(1);
108-
$cache->shouldReceive('get')->once()->with('dingo:api:reset:'.$ip)->andReturn(time() + 60);
108+
$cache->shouldReceive('get')->once()->with('dingo:api:reset:'.$ip);
109109

110110
$app->shouldReceive('handle')->once()->with($request, HttpKernelInterface::MASTER_REQUEST, true)->andReturn($response);
111111
$response = $middleware->handle($request);
@@ -137,10 +137,10 @@ public function testForbiddenResponseIsReturnedWhenRateLimitIsExceeded()
137137
$ip = $request->getClientIp();
138138

139139
$cache->shouldReceive('add')->once()->with('dingo:api:limit:'.$ip, 0, 1);
140-
$cache->shouldReceive('add')->once()->with('dingo:api:reset:'.$ip, time() + 60, 1);
140+
$cache->shouldReceive('add')->once();
141141
$cache->shouldReceive('increment')->once()->with('dingo:api:limit:'.$ip);
142142
$cache->shouldReceive('get')->once()->with('dingo:api:limit:'.$ip)->andReturn(2);
143-
$cache->shouldReceive('get')->once()->with('dingo:api:reset:'.$ip)->andReturn(time() + 60);
143+
$cache->shouldReceive('get')->once()->with('dingo:api:reset:'.$ip);
144144

145145
$response = $middleware->handle($request);
146146
$this->assertEquals(1, $response->headers->get('X-RateLimit-Limit'));

0 commit comments

Comments
 (0)