originalStoreIsWrappedInRetryStore()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 11
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ShlinkioTest\Shlink\Common\Lock;
6
7
use Laminas\ServiceManager\ServiceManager;
8
use PHPUnit\Framework\TestCase;
9
use Prophecy\PhpUnit\ProphecyTrait;
10
use ReflectionObject;
11
use Shlinkio\Shlink\Common\Lock\RetryLockStoreDelegatorFactory;
12
use Symfony\Component\Lock\PersistingStoreInterface;
13
14
class RetryLockStoreDelegatorFactoryTest extends TestCase
15
{
16
    use ProphecyTrait;
17
18
    private RetryLockStoreDelegatorFactory $delegator;
19
    private PersistingStoreInterface $originalStore;
20
21
    public function setUp(): void
22
    {
23
        $this->originalStore = $this->prophesize(PersistingStoreInterface::class)->reveal();
24
        $this->delegator = new RetryLockStoreDelegatorFactory();
25
    }
26
27
    /** @test */
28
    public function originalStoreIsWrappedInRetryStore(): void
29
    {
30
        $callback = fn () => $this->originalStore;
31
32
        $result = ($this->delegator)(new ServiceManager(), '', $callback);
33
34
        $ref = new ReflectionObject($result);
35
        $prop = $ref->getProperty('decorated');
36
        $prop->setAccessible(true);
37
38
        $this->assertSame($this->originalStore, $prop->getValue($result));
39
    }
40
}
41