diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index 4d4df67..28cd3c7 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -12,7 +12,5 @@ jobs: with: os: >- ['ubuntu-latest'] - php: >- - ['8.1', '8.2'] stability: >- ['prefer-stable'] diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml index 3bf6b3a..eea1d20 100644 --- a/.github/workflows/psalm.yml +++ b/.github/workflows/psalm.yml @@ -12,5 +12,3 @@ jobs: with: os: >- ['ubuntu-latest'] - php: >- - ['8.1'] diff --git a/README.md b/README.md index c174f4a..427aa03 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ [![Latest Stable Version](https://poser.pugx.org/roadrunner-php/symfony-lock-driver/v/stable)](https://packagist.org/packages/roadrunner-php/symfony-lock-driver) [![phpunit](https://github.com/roadrunner-php/symfony-lock-driver/actions/workflows/phpunit.yml/badge.svg)](https://github.com/roadrunner-php/symfony-lock-driver/actions) [![psalm](https://github.com/roadrunner-php/symfony-lock-driver/actions/workflows/psalm.yml/badge.svg)](https://github.com/roadrunner-php/symfony-lock-driver/actions) -[![Codecov](https://codecov.io/gh/roadrunner-php/symfony-lock-driver/branch/master/graph/badge.svg)](https://codecov.io/gh/roadrunner-php/symfony-lock-driver/) +[![Codecov](https://codecov.io/gh/roadrunner-php/symfony-lock-driver/branch/1.x/graph/badge.svg)](https://codecov.io/gh/roadrunner-php/symfony-lock-driver/) [![Total Downloads](https://poser.pugx.org/roadrunner-php/symfony-lock-driver/downloads)](https://packagist.org/roadrunner-php/symfony-lock-driver/phpunit) diff --git a/composer.json b/composer.json index 8eefe59..cb34729 100644 --- a/composer.json +++ b/composer.json @@ -20,9 +20,9 @@ "email": "gam6itko@gmail.com" } ], - "homepage": "https://spiral.dev/", + "homepage": "https://roadrunner.dev", "support": { - "docs": "https://roadrunner.dev/docs", + "docs": "https://docs.roadrunner.dev", "issues": "https://github.com/roadrunner-server/roadrunner/issues", "forum": "https://forum.roadrunner.dev/", "chat": "https://discord.gg/V6EK4he" diff --git a/psalm.xml b/psalm.xml index dd76fea..224d8cb 100644 --- a/psalm.xml +++ b/psalm.xml @@ -4,6 +4,8 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="https://getpsalm.org/schema/config" xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" + findUnusedBaselineEntry="true" + findUnusedCode="false" > diff --git a/src/RoadRunnerStore.php b/src/RoadRunnerStore.php index 85ea9ff..cda3a8c 100644 --- a/src/RoadRunnerStore.php +++ b/src/RoadRunnerStore.php @@ -9,7 +9,6 @@ use Symfony\Component\Lock\BlockingStoreInterface; use Symfony\Component\Lock\Exception\LockAcquiringException; use Symfony\Component\Lock\Exception\LockConflictedException; -use Symfony\Component\Lock\Exception\LockReleasingException; use Symfony\Component\Lock\Key; use Symfony\Component\Lock\SharedLockStoreInterface; use Symfony\Component\Lock\Store\ExpiringStoreTrait; @@ -122,8 +121,8 @@ public function waitAndSave(Key $key): void $status = $this->lock->lock($resource, $lockId, $this->initialTtl, $this->initialWaitTtl); $key->setState(__CLASS__, $lockId); - if (!$status) { - throw new LockConflictedException(); + if ($status === false) { + throw new LockConflictedException('RoadRunner. Failed to make lock'); } $this->checkNotExpired($key); diff --git a/tests/RoadRunnerStoreTest.php b/tests/RoadRunnerStoreTest.php index c9aa519..1d74891 100644 --- a/tests/RoadRunnerStoreTest.php +++ b/tests/RoadRunnerStoreTest.php @@ -161,4 +161,33 @@ public function testDeleteFail(): void $key->setState(RoadRunnerStore::class, 'lock-id'); $store->delete($key); } + + public function testWaitAndSaveSuccess(): void + { + $this->rrLock->expects($this->once()) + ->method('lock') + ->with('resource-name', 'random-id', 300, 60) + ->willReturn('lock-id'); + + $store = new RoadRunnerStore($this->rrLock, $this->tokens); + $key = new Key('resource-name'); + $store->waitAndSave($key); + + $this->assertTrue($key->hasState(RoadRunnerStore::class)); + $this->assertSame('random-id', $key->getState(RoadRunnerStore::class)); + } + + public function testWaitAndSaveFail(): void + { + $this->expectException(LockConflictedException::class); + $this->expectExceptionMessage('RoadRunner. Failed to make lock'); + + $this->rrLock->expects($this->once()) + ->method('lock') + ->with('resource-name', 'random-id', 300, 60) + ->willReturn(false); + + $store = new RoadRunnerStore($this->rrLock, $this->tokens); + $store->waitAndSave(new Key('resource-name')); + } }