[Lock] remove deprecated code
This commit is contained in:
parent
663144702c
commit
008d135247
@ -68,14 +68,12 @@ use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
|||||||
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
|
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
|
||||||
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
|
use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface;
|
||||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||||
use Symfony\Component\Lock\Factory;
|
|
||||||
use Symfony\Component\Lock\Lock;
|
use Symfony\Component\Lock\Lock;
|
||||||
use Symfony\Component\Lock\LockFactory;
|
use Symfony\Component\Lock\LockFactory;
|
||||||
use Symfony\Component\Lock\LockInterface;
|
use Symfony\Component\Lock\LockInterface;
|
||||||
use Symfony\Component\Lock\PersistingStoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
use Symfony\Component\Lock\Store\FlockStore;
|
use Symfony\Component\Lock\Store\FlockStore;
|
||||||
use Symfony\Component\Lock\Store\StoreFactory;
|
use Symfony\Component\Lock\Store\StoreFactory;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
|
||||||
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
|
use Symfony\Component\Mailer\Bridge\Amazon\Transport\SesTransportFactory;
|
||||||
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
|
use Symfony\Component\Mailer\Bridge\Google\Transport\GmailTransportFactory;
|
||||||
use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
|
use Symfony\Component\Mailer\Bridge\Mailchimp\Transport\MandrillTransportFactory;
|
||||||
@ -1499,15 +1497,11 @@ class FrameworkExtension extends Extension
|
|||||||
$container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store', false));
|
$container->setAlias('lock.store', new Alias('lock.'.$resourceName.'.store', false));
|
||||||
$container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false));
|
$container->setAlias('lock.factory', new Alias('lock.'.$resourceName.'.factory', false));
|
||||||
$container->setAlias('lock', new Alias('lock.'.$resourceName, false));
|
$container->setAlias('lock', new Alias('lock.'.$resourceName, false));
|
||||||
$container->setAlias(StoreInterface::class, new Alias('lock.store', false));
|
|
||||||
$container->setAlias(PersistingStoreInterface::class, new Alias('lock.store', false));
|
$container->setAlias(PersistingStoreInterface::class, new Alias('lock.store', false));
|
||||||
$container->setAlias(Factory::class, new Alias('lock.factory', false));
|
|
||||||
$container->setAlias(LockFactory::class, new Alias('lock.factory', false));
|
$container->setAlias(LockFactory::class, new Alias('lock.factory', false));
|
||||||
$container->setAlias(LockInterface::class, new Alias('lock', false));
|
$container->setAlias(LockInterface::class, new Alias('lock', false));
|
||||||
} else {
|
} else {
|
||||||
$container->registerAliasForArgument('lock.'.$resourceName.'.store', StoreInterface::class, $resourceName.'.lock.store');
|
|
||||||
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistingStoreInterface::class, $resourceName.'.lock.store');
|
$container->registerAliasForArgument('lock.'.$resourceName.'.store', PersistingStoreInterface::class, $resourceName.'.lock.store');
|
||||||
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', Factory::class, $resourceName.'.lock.factory');
|
|
||||||
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory');
|
$container->registerAliasForArgument('lock.'.$resourceName.'.factory', LockFactory::class, $resourceName.'.lock.factory');
|
||||||
$container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock');
|
$container->registerAliasForArgument('lock.'.$resourceName, LockInterface::class, $resourceName.'.lock');
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
=========
|
=========
|
||||||
|
|
||||||
|
5.0.0
|
||||||
|
-----
|
||||||
|
|
||||||
|
* `Factory` has been removed, use `LockFactory` instead.
|
||||||
|
* `StoreInterface` has been removed, use `BlockingStoreInterface` and `PersistingStoreInterface` instead.
|
||||||
|
|
||||||
4.4.0
|
4.4.0
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Lock;
|
|
||||||
|
|
||||||
use Psr\Log\LoggerAwareInterface;
|
|
||||||
use Psr\Log\LoggerAwareTrait;
|
|
||||||
use Psr\Log\NullLogger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory provides method to create locks.
|
|
||||||
*
|
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
|
||||||
*
|
|
||||||
* @deprecated "Symfony\Component\Lock\Factory" is deprecated since Symfony 4.4 and will be removed in 5.0 use "Symfony\Component\Lock\LockFactory" instead
|
|
||||||
*/
|
|
||||||
class Factory implements LoggerAwareInterface
|
|
||||||
{
|
|
||||||
use LoggerAwareTrait;
|
|
||||||
|
|
||||||
private $store;
|
|
||||||
|
|
||||||
public function __construct(StoreInterface $store)
|
|
||||||
{
|
|
||||||
$this->store = $store;
|
|
||||||
|
|
||||||
$this->logger = new NullLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a lock for the given resource.
|
|
||||||
*
|
|
||||||
* @param string $resource The resource to lock
|
|
||||||
* @param float|null $ttl Maximum expected lock duration in seconds
|
|
||||||
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
|
|
||||||
*
|
|
||||||
* @return Lock
|
|
||||||
*/
|
|
||||||
public function createLock($resource, $ttl = 300.0, $autoRelease = true)
|
|
||||||
{
|
|
||||||
$lock = new Lock(new Key($resource), $this->store, $ttl, $autoRelease);
|
|
||||||
$lock->setLogger($this->logger);
|
|
||||||
|
|
||||||
return $lock;
|
|
||||||
}
|
|
||||||
}
|
|
@ -71,7 +71,7 @@ final class Lock implements LockInterface, LoggerAwareInterface
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
if ($blocking) {
|
if ($blocking) {
|
||||||
if (!$this->store instanceof StoreInterface && !$this->store instanceof BlockingStoreInterface) {
|
if (!$this->store instanceof BlockingStoreInterface) {
|
||||||
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store)));
|
throw new NotSupportedException(sprintf('The store "%s" does not support blocking locks.', \get_class($this->store)));
|
||||||
}
|
}
|
||||||
$this->store->waitAndSave($this->key);
|
$this->store->waitAndSave($this->key);
|
||||||
|
@ -11,14 +11,29 @@
|
|||||||
|
|
||||||
namespace Symfony\Component\Lock;
|
namespace Symfony\Component\Lock;
|
||||||
|
|
||||||
|
use Psr\Log\LoggerAwareInterface;
|
||||||
|
use Psr\Log\LoggerAwareTrait;
|
||||||
|
use Psr\Log\NullLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Factory provides method to create locks.
|
* Factory provides method to create locks.
|
||||||
*
|
*
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
|
* @author Hamza Amrouche <hamza.simperfit@gmail.com>
|
||||||
*/
|
*/
|
||||||
class LockFactory extends Factory
|
class LockFactory implements LoggerAwareInterface
|
||||||
{
|
{
|
||||||
|
use LoggerAwareTrait;
|
||||||
|
|
||||||
|
private $store;
|
||||||
|
|
||||||
|
public function __construct(PersistingStoreInterface $store)
|
||||||
|
{
|
||||||
|
$this->store = $store;
|
||||||
|
|
||||||
|
$this->logger = new NullLogger();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a lock for the given resource.
|
* Creates a lock for the given resource.
|
||||||
*
|
*
|
||||||
@ -26,8 +41,11 @@ class LockFactory extends Factory
|
|||||||
* @param float|null $ttl Maximum expected lock duration in seconds
|
* @param float|null $ttl Maximum expected lock duration in seconds
|
||||||
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
|
* @param bool $autoRelease Whether to automatically release the lock or not when the lock instance is destroyed
|
||||||
*/
|
*/
|
||||||
public function createLock($resource, $ttl = 300.0, $autoRelease = true): Lock
|
public function createLock(string $resource, ?float $ttl = 300.0, bool $autoRelease = true): Lock
|
||||||
{
|
{
|
||||||
return parent::createLock($resource, $ttl, $autoRelease);
|
$lock = new Lock(new Key($resource), $this->store, $ttl, $autoRelease);
|
||||||
|
$lock->setLogger($this->logger);
|
||||||
|
|
||||||
|
return $lock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ use Symfony\Component\Lock\Exception\LockConflictedException;
|
|||||||
use Symfony\Component\Lock\Exception\NotSupportedException;
|
use Symfony\Component\Lock\Exception\NotSupportedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\PersistingStoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
|
||||||
use Symfony\Component\Lock\Strategy\StrategyInterface;
|
use Symfony\Component\Lock\Strategy\StrategyInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +26,7 @@ use Symfony\Component\Lock\Strategy\StrategyInterface;
|
|||||||
*
|
*
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*/
|
*/
|
||||||
class CombinedStore implements StoreInterface, LoggerAwareInterface
|
class CombinedStore implements PersistingStoreInterface, LoggerAwareInterface
|
||||||
{
|
{
|
||||||
use LoggerAwareTrait;
|
use LoggerAwareTrait;
|
||||||
use ExpiringStoreTrait;
|
use ExpiringStoreTrait;
|
||||||
|
@ -16,7 +16,7 @@ use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
|||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
use Symfony\Component\Lock\Exception\LockConflictedException;
|
||||||
use Symfony\Component\Lock\Exception\LockStorageException;
|
use Symfony\Component\Lock\Exception\LockStorageException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FlockStore is a PersistingStoreInterface implementation using the FileSystem flock.
|
* FlockStore is a PersistingStoreInterface implementation using the FileSystem flock.
|
||||||
@ -28,7 +28,7 @@ use Symfony\Component\Lock\StoreInterface;
|
|||||||
* @author Romain Neutron <imprec@gmail.com>
|
* @author Romain Neutron <imprec@gmail.com>
|
||||||
* @author Nicolas Grekas <p@tchwork.com>
|
* @author Nicolas Grekas <p@tchwork.com>
|
||||||
*/
|
*/
|
||||||
class FlockStore implements StoreInterface, BlockingStoreInterface
|
class FlockStore implements PersistingStoreInterface, BlockingStoreInterface
|
||||||
{
|
{
|
||||||
private $lockPath;
|
private $lockPath;
|
||||||
|
|
||||||
|
@ -15,14 +15,14 @@ use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
|||||||
use Symfony\Component\Lock\Exception\InvalidTtlException;
|
use Symfony\Component\Lock\Exception\InvalidTtlException;
|
||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
use Symfony\Component\Lock\Exception\LockConflictedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MemcachedStore is a PersistingStoreInterface implementation using Memcached as store engine.
|
* MemcachedStore is a PersistingStoreInterface implementation using Memcached as store engine.
|
||||||
*
|
*
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*/
|
*/
|
||||||
class MemcachedStore implements StoreInterface
|
class MemcachedStore implements PersistingStoreInterface
|
||||||
{
|
{
|
||||||
use ExpiringStoreTrait;
|
use ExpiringStoreTrait;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Lock\Exception\InvalidTtlException;
|
|||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
use Symfony\Component\Lock\Exception\LockConflictedException;
|
||||||
use Symfony\Component\Lock\Exception\NotSupportedException;
|
use Symfony\Component\Lock\Exception\NotSupportedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PdoStore is a PersistingStoreInterface implementation using a PDO connection.
|
* PdoStore is a PersistingStoreInterface implementation using a PDO connection.
|
||||||
@ -34,7 +34,7 @@ use Symfony\Component\Lock\StoreInterface;
|
|||||||
*
|
*
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*/
|
*/
|
||||||
class PdoStore implements StoreInterface
|
class PdoStore implements PersistingStoreInterface
|
||||||
{
|
{
|
||||||
use ExpiringStoreTrait;
|
use ExpiringStoreTrait;
|
||||||
|
|
||||||
|
@ -17,14 +17,14 @@ use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
|||||||
use Symfony\Component\Lock\Exception\InvalidTtlException;
|
use Symfony\Component\Lock\Exception\InvalidTtlException;
|
||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
use Symfony\Component\Lock\Exception\LockConflictedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RedisStore is a PersistingStoreInterface implementation using Redis as store engine.
|
* RedisStore is a PersistingStoreInterface implementation using Redis as store engine.
|
||||||
*
|
*
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*/
|
*/
|
||||||
class RedisStore implements StoreInterface
|
class RedisStore implements PersistingStoreInterface
|
||||||
{
|
{
|
||||||
use ExpiringStoreTrait;
|
use ExpiringStoreTrait;
|
||||||
|
|
||||||
|
@ -18,7 +18,6 @@ use Symfony\Component\Lock\BlockingStoreInterface;
|
|||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
use Symfony\Component\Lock\Exception\LockConflictedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\PersistingStoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RetryTillSaveStore is a PersistingStoreInterface implementation which decorate a non blocking PersistingStoreInterface to provide a
|
* RetryTillSaveStore is a PersistingStoreInterface implementation which decorate a non blocking PersistingStoreInterface to provide a
|
||||||
@ -26,7 +25,7 @@ use Symfony\Component\Lock\StoreInterface;
|
|||||||
*
|
*
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*/
|
*/
|
||||||
class RetryTillSaveStore implements BlockingStoreInterface, StoreInterface, LoggerAwareInterface
|
class RetryTillSaveStore implements BlockingStoreInterface, LoggerAwareInterface
|
||||||
{
|
{
|
||||||
use LoggerAwareTrait;
|
use LoggerAwareTrait;
|
||||||
|
|
||||||
|
@ -15,14 +15,13 @@ use Symfony\Component\Lock\BlockingStoreInterface;
|
|||||||
use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
use Symfony\Component\Lock\Exception\InvalidArgumentException;
|
||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
use Symfony\Component\Lock\Exception\LockConflictedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SemaphoreStore is a PersistingStoreInterface implementation using Semaphore as store engine.
|
* SemaphoreStore is a PersistingStoreInterface implementation using Semaphore as store engine.
|
||||||
*
|
*
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
*/
|
*/
|
||||||
class SemaphoreStore implements StoreInterface, BlockingStoreInterface
|
class SemaphoreStore implements BlockingStoreInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Returns whether or not the store is supported.
|
* Returns whether or not the store is supported.
|
||||||
|
@ -16,14 +16,14 @@ use Symfony\Component\Lock\Exception\LockConflictedException;
|
|||||||
use Symfony\Component\Lock\Exception\LockReleasingException;
|
use Symfony\Component\Lock\Exception\LockReleasingException;
|
||||||
use Symfony\Component\Lock\Exception\NotSupportedException;
|
use Symfony\Component\Lock\Exception\NotSupportedException;
|
||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ZookeeperStore is a PersistingStoreInterface implementation using Zookeeper as store engine.
|
* ZookeeperStore is a PersistingStoreInterface implementation using Zookeeper as store engine.
|
||||||
*
|
*
|
||||||
* @author Ganesh Chandrasekaran <gchandrasekaran@wayfair.com>
|
* @author Ganesh Chandrasekaran <gchandrasekaran@wayfair.com>
|
||||||
*/
|
*/
|
||||||
class ZookeeperStore implements StoreInterface
|
class ZookeeperStore implements PersistingStoreInterface
|
||||||
{
|
{
|
||||||
use ExpiringStoreTrait;
|
use ExpiringStoreTrait;
|
||||||
|
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Lock;
|
|
||||||
|
|
||||||
use Symfony\Component\Lock\Exception\LockConflictedException;
|
|
||||||
use Symfony\Component\Lock\Exception\NotSupportedException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* StoreInterface defines an interface to manipulate a lock store.
|
|
||||||
*
|
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
|
||||||
*
|
|
||||||
* @deprecated since Symfony 4.4, use PersistingStoreInterface and BlockingStoreInterface instead
|
|
||||||
*/
|
|
||||||
interface StoreInterface extends PersistingStoreInterface
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Waits until a key becomes free, then stores the resource.
|
|
||||||
*
|
|
||||||
* If the store does not support this feature it should throw a NotSupportedException.
|
|
||||||
*
|
|
||||||
* @throws LockConflictedException
|
|
||||||
* @throws NotSupportedException
|
|
||||||
*/
|
|
||||||
public function waitAndSave(Key $key);
|
|
||||||
}
|
|
@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of the Symfony package.
|
|
||||||
*
|
|
||||||
* (c) Fabien Potencier <fabien@symfony.com>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Symfony\Component\Lock\Tests;
|
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
|
||||||
use Psr\Log\LoggerInterface;
|
|
||||||
use Symfony\Component\Lock\Factory;
|
|
||||||
use Symfony\Component\Lock\LockInterface;
|
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
|
||||||
*/
|
|
||||||
class FactoryTest extends TestCase
|
|
||||||
{
|
|
||||||
public function testCreateLock()
|
|
||||||
{
|
|
||||||
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
|
|
||||||
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
|
|
||||||
$factory = new Factory($store);
|
|
||||||
$factory->setLogger($logger);
|
|
||||||
|
|
||||||
$lock = $factory->createLock('foo');
|
|
||||||
|
|
||||||
$this->assertInstanceOf(LockInterface::class, $lock);
|
|
||||||
}
|
|
||||||
}
|
|
@ -15,7 +15,7 @@ use PHPUnit\Framework\TestCase;
|
|||||||
use Psr\Log\LoggerInterface;
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Component\Lock\LockFactory;
|
use Symfony\Component\Lock\LockFactory;
|
||||||
use Symfony\Component\Lock\LockInterface;
|
use Symfony\Component\Lock\LockInterface;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
@ -24,7 +24,7 @@ class LockFactoryTest extends TestCase
|
|||||||
{
|
{
|
||||||
public function testCreateLock()
|
public function testCreateLock()
|
||||||
{
|
{
|
||||||
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
|
$store = $this->getMockBuilder(PersistingStoreInterface::class)->getMock();
|
||||||
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
|
$logger = $this->getMockBuilder(LoggerInterface::class)->getMock();
|
||||||
$factory = new LockFactory($store);
|
$factory = new LockFactory($store);
|
||||||
$factory->setLogger($logger);
|
$factory->setLogger($logger);
|
||||||
|
@ -18,7 +18,6 @@ use Symfony\Component\Lock\Exception\LockConflictedException;
|
|||||||
use Symfony\Component\Lock\Key;
|
use Symfony\Component\Lock\Key;
|
||||||
use Symfony\Component\Lock\Lock;
|
use Symfony\Component\Lock\Lock;
|
||||||
use Symfony\Component\Lock\PersistingStoreInterface;
|
use Symfony\Component\Lock\PersistingStoreInterface;
|
||||||
use Symfony\Component\Lock\StoreInterface;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jérémy Derussé <jeremy@derusse.com>
|
* @author Jérémy Derussé <jeremy@derusse.com>
|
||||||
@ -51,22 +50,6 @@ class LockTest extends TestCase
|
|||||||
$this->assertTrue($lock->acquire(false));
|
$this->assertTrue($lock->acquire(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @group legacy
|
|
||||||
*/
|
|
||||||
public function testPassingOldStoreInterface()
|
|
||||||
{
|
|
||||||
$key = new Key(uniqid(__METHOD__, true));
|
|
||||||
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
|
|
||||||
$lock = new Lock($key, $store);
|
|
||||||
|
|
||||||
$store
|
|
||||||
->expects($this->once())
|
|
||||||
->method('save');
|
|
||||||
|
|
||||||
$this->assertTrue($lock->acquire(false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testAcquireReturnsFalse()
|
public function testAcquireReturnsFalse()
|
||||||
{
|
{
|
||||||
$key = new Key(uniqid(__METHOD__, true));
|
$key = new Key(uniqid(__METHOD__, true));
|
||||||
|
Reference in New Issue
Block a user