public function testSetLockReturnsFalse() { $adapterMock = $this->getMock('BeaucalLongThrottle\\Adapter\\Apc', ['setLock'], [new ApcExt(), $this->apcAdapter->getOptions(), new LockHandleFactory()]); $adapterMock->expects($this->any())->method('setLock')->will($this->returnValue(false)); $throttle = new Throttle($adapterMock, new ThrottleOptions()); $this->assertFalse($throttle->takeLock('setLockReturnsFalse', new DateTimeUnit(3, 'minutes'))); }
public function testSetLockPast() { $this->assertFalse($this->apcAdapter->setLock('past', new DateTime('2000-01-01'))); $this->assertTrue((bool) $this->apcAdapter->setLock('past', (new DateTime())->modify('+1 hour'))); }