Skip to content

Commit

Permalink
minor #32562 [Lock] remove usage of the StoreInterface (Simperfit)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[Lock] remove usage of the StoreInterface

| Q             | A
| ------------- | ---
| Branch?       |4.4
| Bug fix?      |  no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| BC breaks?    | no     <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass?   | yes    <!-- please add some, will be required by reviewers -->
| Fixed tickets |    <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | none  <!-- required for new features -->

<!--
Replace this notice by a short README for your feature/bugfix. This will help people
understand your PR and can be used as a start for the documentation.

Additionally (see https://symfony.com/roadmap):
 - Bug fixes must be submitted against the lowest maintained branch where they apply
   (lowest branches are regularly merged to upper ones so they get the fixes too).
 - Features and deprecations must be submitted against branch 4.4.
 - Legacy code removals go to the master branch.
-->

Followup PR according to the review of @nicolas-grekas in #32555 (comment).

Commits
-------

9988844 [Lock] remove uusage of the StoreInterface
  • Loading branch information
fabpot committed Jul 17, 2019
2 parents e5ad989 + 9988844 commit 25f1804
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1606,7 +1606,7 @@ private function registerLockConfiguration(array $config, ContainerBuilder $cont
$container->setDefinition($connectionDefinitionId, $connectionDefinition);
}

$storeDefinition = new Definition(StoreInterface::class);
$storeDefinition = new Definition(PersistStoreInterface::class);
$storeDefinition->setPublic(false);
$storeDefinition->setFactory([StoreFactory::class, 'createStore']);
$storeDefinition->setArguments([new Reference($connectionDefinitionId)]);
Expand Down
17 changes: 8 additions & 9 deletions src/Symfony/Component/Lock/Tests/LockTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\Lock;
use Symfony\Component\Lock\PersistStoreInterface;
use Symfony\Component\Lock\StoreInterface;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
Expand All @@ -41,7 +40,7 @@ public function testAcquireNoBlocking()
public function testAcquireNoBlockingStoreInterface()
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store);

$store
Expand All @@ -59,7 +58,7 @@ public function testAcquireNoBlockingStoreInterface()
public function testPassingOldStoreInterface()
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store);

$store
Expand All @@ -86,7 +85,7 @@ public function testAcquireReturnsFalse()
public function testAcquireReturnsFalseStoreInterface()
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store);

$store
Expand Down Expand Up @@ -121,7 +120,7 @@ public function testAcquireBlocking()
public function testAcquireSetsTtl()
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10);

$store
Expand All @@ -138,7 +137,7 @@ public function testAcquireSetsTtl()
public function testRefresh()
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10);

$store
Expand All @@ -152,7 +151,7 @@ public function testRefresh()
public function testRefreshCustom()
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10);

$store
Expand Down Expand Up @@ -201,7 +200,7 @@ public function testRelease()
public function testReleaseStoreInterface()
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10);

$store
Expand Down Expand Up @@ -356,7 +355,7 @@ public function testExpiration($ttls, $expected)
public function testExpirationStoreInterface($ttls, $expected)
{
$key = new Key(uniqid(__METHOD__, true));
$store = $this->getMockBuilder(StoreInterface::class)->getMock();
$store = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$lock = new Lock($key, $store, 10);

foreach ($ttls as $ttl) {
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Lock/Tests/Store/AbstractStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistStoreInterface;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
*/
abstract class AbstractStoreTest extends TestCase
{
/**
* @return StoreInterface
* @return PersistStoreInterface
*/
abstract protected function getStore();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Lock\Exception\LockConflictedException;
use Symfony\Component\Lock\Exception\NotSupportedException;
use Symfony\Component\Lock\Key;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\PersistStoreInterface;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
Expand All @@ -24,7 +24,7 @@ trait BlockingStoreTestTrait
/**
* @see AbstractStoreTest::getStore()
*
* @return StoreInterface
* @return PersistStoreInterface
*/
abstract protected function getStore();

Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Lock/Tests/Store/CombinedStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Symfony\Component\Lock\PersistStoreInterface;
use Symfony\Component\Lock\Store\CombinedStore;
use Symfony\Component\Lock\Store\RedisStore;
use Symfony\Component\Lock\StoreInterface;
use Symfony\Component\Lock\Strategy\StrategyInterface;
use Symfony\Component\Lock\Strategy\UnanimousStrategy;

Expand Down Expand Up @@ -268,8 +267,8 @@ public function testputOffExpirationAbortWhenStrategyCantBeMet()

public function testPutOffExpirationIgnoreNonExpiringStorage()
{
$store1 = $this->getMockBuilder(StoreInterface::class)->getMock();
$store2 = $this->getMockBuilder(StoreInterface::class)->getMock();
$store1 = $this->getMockBuilder(PersistStoreInterface::class)->getMock();
$store2 = $this->getMockBuilder(PersistStoreInterface::class)->getMock();

$store = new CombinedStore([$store1, $store2], $this->strategy);

Expand Down

0 comments on commit 25f1804

Please sign in to comment.