Stiphle\Storage\ProcessTest::testLockRespectsLockWaitTimeoutValue PHP Method

testLockRespectsLockWaitTimeoutValue() public method

    public function testLockRespectsLockWaitTimeoutValue()
    {
        /**
         * Test we can do this 
         */
        $this->storage->lock('dave');
        try {
            $start = microtime(1);
            $this->storage->lock('dave');
        } catch (LockWaitTimeoutException $e) {
            $caught = microtime(1);
            $diff = $caught - $start;
            if (round($diff) != 1) {
                $this->markTestSkipped("Don't think the timings will be accurate enough, expected exception after 1 second, was {$diff}");
            }
        }
        $this->storage->setLockWaitTimeout(2000);
        try {
            $start = microtime(1);
            $this->storage->lock('dave');
            $this->fail("should not get to this point");
        } catch (LockWaitTimeoutException $e) {
            $caught = microtime(1);
            $diff = $caught - $start;
            $this->assertEquals(2, round($diff), "Exception thrown after approximately 2000 milliseconds");
        }
    }