@@ -16,20 +16,19 @@ public function testTokenTime()
1616 {
1717 $ throttler = new Throttler ($ this ->cache );
1818
19- // token time should be zero to start
19+ // tokenTime should be 0 to start
2020 $ this ->assertEquals (0 , $ throttler ->getTokenTime ());
2121
22- // as soon as we try a rate check, token time affected
23- $ rate = 1 ; // allow 1 per minute
24- $ cost = 1 ;
22+ // set $rate
23+ $ rate = 1 ; // allow 1 request per minute
2524
26- // after using one slot, still good
27- $ throttler ->check ('127.0.0.1 ' , $ rate , MINUTE , $ cost );
25+ // first check just creates a bucket, so tokenTime should be 0
26+ $ throttler ->check ('127.0.0.1 ' , $ rate , MINUTE );
2827 $ this ->assertEquals (0 , $ throttler ->getTokenTime ());
2928
30- // after consuming a second, we have to wait
31- $ throttler ->check ('127.0.0.1 ' , $ rate , MINUTE , $ cost );
32- $ this ->assertEquals (1 , $ throttler ->getTokenTime ());
29+ // additional check affects tokenTime, so tokenTime should be 1 or greater
30+ $ throttler ->check ('127.0.0.1 ' , $ rate , MINUTE );
31+ $ this ->assertGreaterThanOrEqual (1 , $ throttler ->getTokenTime ());
3332 }
3433
3534 public function testIPSavesBucket ()
0 commit comments