makeManager(1); $document = new StoredObject(); $request = $this->prophesize(RequestInterface::class); $this->assertFalse($manager->hasLock($document, $request->reveal())); $this->assertTrue($manager->setLock($document, 'dummy', $request->reveal())); $this->assertEquals('dummy', $manager->getLock($document, $request->reveal())); $this->assertTrue($manager->setLock($document, 'bar', $request->reveal())); $this->assertEquals('bar', $manager->getLock($document, $request->reveal())); $this->assertTrue($manager->deleteLock($document, $request->reveal())); sleep(3); // wait for redis to remove the key $this->assertFalse($manager->hasLock($document, $request->reveal())); } public function testSingleLock() { $manager = $this->makeManager(1); $document = new StoredObject(); $request = $this->prophesize(RequestInterface::class); $this->assertFalse($manager->hasLock($document, $request->reveal())); $this->assertTrue($manager->setLock($document, 'dummy', $request->reveal())); $this->assertEquals('dummy', $manager->getLock($document, $request->reveal())); $this->assertTrue($manager->deleteLock($document, $request->reveal())); sleep(3); // wait for redis to remove the key $this->assertFalse($manager->hasLock($document, $request->reveal())); } private function makeManager(int $ttlAfterDeleteSeconds = -1): ChillDocumentLockManager { $redis = self::$container->get(ChillRedis::class); return new ChillDocumentLockManager($redis, $ttlAfterDeleteSeconds); } }