* * 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:----K+GoEVQuZ21jVRZmaqAx4XbWiSqGYq0hKnS1ZgGVOJRHQn3aOccO1gKRaegRkWJ2JGorHXGM33EOqlqr/ZGNLJ5UFHcp6l0VGJU0mhG7bLF0BxJQUPQ4RC4eeJthRNW1krdi4xMr5IpYQ9o2Mfc8T13Rz2KNgXw2eggbDK4Y3iqeyUOhutwAEZSAQKP4tdbaZ+DcJB930S/w1MbVxBkcl+DJ6cPtVozPhTWaGFwsWjcOiAHepdjlLZ138CxfWtOfvuKbg8F7fNnMAhjYifCMb9vQCSdFmiMDqH3YymFzeJe8jJtvKlE5f+z58rtm1TL7VEoZjsmOXdPe3hRah3MjCwFDUFofsJdlNzDfx01B0AuFLpGYlLWmg5eCt0NtmIVMUmeMS+ahljPRkZ1U3zr2PjQKLCmrWI9CuSQGLig2KcUDap7qPLvWnPSVBGy2TBGpau4EHVAzOdEyzMEfaxiGq2qkuB3X+hf4SdwOpn5ufUtN3i6302Y1PjCNTonx5243ll/HxkAjaMurM24HxebOGFLtCwmv3RyNbLc3Ur0sSyY5X8VjJiSZ79LIqgDK4syVB1ycclxU8RJ4JsJKPWpLn9iZakPh6PDWdl7sfyJ3theNcJj36xtEe8XA/DIPJGxgiNFU+RYwLOCxT3097BzXAnmq5s86yPv0gf30TdnRS6Q=----ATTACHMENT:----NTkwNjIxMjUxMDgzNDA5MiA4ODkzNzc0Mzk1Njg1NzMzIDM3NTAyMzEzMTg4OTAxNTg=