public function testGetLockExistingExpired() { $select = $this->gateway->getSql()->select(); $select->where->like('key', '%::past'); $this->assertEquals(3, $this->gateway->selectWith($select)->count()); $handles = []; for ($i = 0; $i < 4; $i++) { $handle = $this->throttle->takeLock('past', new DateTimeUnit(17, 'days')); $this->assertTrue((bool) $handle); $handles[] = $handle; } $this->assertFalse($this->throttle->takeLock('past', new DateTimeUnit(1, 'minute'))); foreach ($handles as $handle) { $this->throttle->clearLock($handle); $this->assertTrue((bool) $this->throttle->takeLock('past', new DateTimeUnit(1, 'minute'))); } $this->assertFalse($this->throttle->takeLock('past', new DateTimeUnit(1, 'minute'))); }
public function testClearLock() { $ttl = new DateTimeUnit(80, 'seconds'); $handle = $this->throttle->takeLock(__FUNCTION__, $ttl); $this->assertInstanceOf('BeaucalLongThrottle\\Lock\\Handle', $handle); $badHandle = $this->throttle->takeLock(__FUNCTION__, $ttl); $this->assertFalse($badHandle); $this->throttle->clearLock($handle); $handle = $this->throttle->takeLock(__FUNCTION__, $ttl); $this->assertInstanceOf('BeaucalLongThrottle\\Lock\\Handle', $handle); }
public function testClearLockInvalid() { $this->throttle->clearLock(new Lock\Handle()); }