Completed
Push — master ( b0bb77...848444 )
by Alejandro
19s queued 11s
created

RetryLockStoreDelegatorFactoryTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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