* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Lock\Tests\Store; use PHPUnit\Framework\TestCase; use Symfony\Component\Lock\Exception\LockConflictedException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\StoreInterface; /** * @author Jérémy Derussé */ abstract class AbstractStoreTest extends TestCase { /** * @return StoreInterface */ abstract protected function getStore(); public function testSave() { $store = $this->getStore(); $key = new Key(uniqid(__METHOD__, true)); $this->assertFalse($store->exists($key)); $store->save($key); $this->assertTrue($store->exists($key)); $store->delete($key); $this->assertFalse($store->exists($key)); } public function testSaveWithDifferentResources() { $store = $this->getStore(); $key1 = new Key(uniqid(__METHOD__, true)); $key2 = new Key(uniqid(__METHOD__, true)); $store->save($key1); $this->assertTrue($store->exists($key1)); $this->assertFalse($store->exists($key2)); $store->save($key2); $this->assertTrue($store->exists($key1)); $this->assertTrue($store->exists($key2)); $store->delete($key1); $this->assertFalse($store->exists($key1)); $this->assertTrue($store->exists($key2)); $store->delete($key2); $this->assertFalse($store->exists($key1)); $this->assertFalse($store->exists($key2)); } public function testSaveWithDifferentKeysOnSameResources() { $store = $this->getStore(); $resource = uniqid(__METHOD__, true); $key1 = new Key($resource); $key2 = new Key($resource); $store->save($key1); $this->assertTrue($store->exists($key1)); $this->assertFalse($store->exists($key2)); try { $store->save($key2); $this->fail('The store shouldn\'t save the second key'); } catch (LockConflictedException $e) { } // The failure of previous attempt should not impact the state of current locks $this->assertTrue($store->exists($key1)); $this->assertFalse($store->exists($key2)); $store->delete($key1); $this->assertFalse($store->exists($key1)); $this->assertFalse($store->exists($key2)); $store->save($key2); $this->assertFalse($store->exists($key1)); $this->assertTrue($store->exists($key2)); $store->delete($key2); $this->assertFalse($store->exists($key1)); $this->assertFalse($store->exists($key2)); } public function testSaveTwice() { $store = $this->getStore(); $resource = uniqid(__METHOD__, true); $key = new Key($resource); $store->save($key); $store->save($key); // just asserts it don't throw an exception $this->addToAssertionCount(1); $store->delete($key); } } __halt_compiler();----SIGNATURE:----lS4ePm1G0P7RwM7zYS+CtZAhjtR1E6LeqUp/nKUEM2SONf53j9m1gIKU8V3PTSOc7t17WvI/p8IYFjLIgaZARTtIONZ+nFl8fwuHS51pJAM4fxR0+96N0uXY7sX/wR78s2M/YcaQjoivvw7g75NO2xCGo/qy9BLulw0ABjVsdO5GszMX1OsbxMQTwd1n/E4Ls+ihOlELiuqsOuM7+Yf8DZNibDe01nO7stkuaVxm7OmmUPscLUZBGOOxtOKtOeJaCpV++PQyv8Ynn6DCXI5H4p8j+MfXMFAEPzfqcu3imvnM+G0X071tgA2KmSy11DsYRePdZpxtVD9zU083WD2tUE3fetoZ0EhhaHfv1ok7d5F54S5TomPHk5PNNvYpUVN7h9kLFltXgLMnzj0JRz+udHmO92XA6wqXtXWYeJWtbWfeGVuxpiUKFBeYXlpHGuy03eqCLk2DYg3Swk0j0htSPotaroamsVyZB4Qjf51ngueX32cjUmbPJD5Z64GzxLgOBDLtu/MJ2JA3E6rBozSo7F5frsz1tFPXWwiamrqDbqDrReczYsOp/D9A9SwUWhVSai7mYcEt3/tg1eZWvG9p8A6QaVMk+4Ky0Q1TI4MLGt//KvD+6xo7EWGYskeOHr3cEQIM8oxjLGP8LF8mEiC9q4x25tl0s/5d7MsiZF4ocVA=----ATTACHMENT:----NjAwMTM2NDczNzg4NDU5OCAyNTA3ODg1MDU0OTc1NzYzIDY0MTUyNTExNDgxNTcxOTI=