Completed
Push — master ( e02e4d...5773dd )
by
unknown
02:54 queued 11s
created

testFailGetDefaultStrategy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.9666
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\QueueBundle\Tests\Unit\Service;
6
7
use Lamoda\QueueBundle\Exception\UnknownStrategyKeyException;
8
use Lamoda\QueueBundle\Strategy\Delay\ArithmeticProgressionStrategy;
9
use Lamoda\QueueBundle\Strategy\Delay\GeometricProgressionStrategy;
10
use PHPUnit_Framework_TestCase;
11
12
class DelayStrategyResolverTest extends PHPUnit_Framework_TestCase
13
{
14
    use DelayStrategyResolverTrait;
15
16 View Code Duplication
    public function testGetStrategy()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
    {
18
        $checkingQueueName = 'queue';
19
        $strategiesByQueues = ['queue' => 'arithmetic_strategy_key'];
20
21
        $resolver = $this->createDelayStrategyResolver($strategiesByQueues);
22
        $strategy = $resolver->getStrategy($checkingQueueName);
23
        $this->assertInstanceOf(ArithmeticProgressionStrategy::class, $strategy);
24
        $this->assertAttributeEquals(100, 'startInterval', $strategy);
25
        $this->assertAttributeEquals(4, 'multiplier', $strategy);
26
    }
27
28 View Code Duplication
    public function testGetDefaultStrategy()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        $checkingQueueName = 'queue';
31
        $strategiesByQueues = [];
32
33
        $resolver = $this->createDelayStrategyResolver($strategiesByQueues);
34
        $strategy = $resolver->getStrategy($checkingQueueName);
35
        $this->assertInstanceOf(GeometricProgressionStrategy::class, $strategy);
36
        $this->assertAttributeEquals(60, 'startInterval', $strategy);
37
        $this->assertAttributeEquals(3, 'multiplier', $strategy);
38
    }
39
40
    public function testFailGetDefaultStrategy()
41
    {
42
        $this->expectException(UnknownStrategyKeyException::class);
43
        $checkingQueueName = 'queue';
44
        $strategiesByQueues = ['queue' => 'unknown_strategy_key'];
45
46
        $resolver = $this->createDelayStrategyResolver($strategiesByQueues);
47
        $resolver->getStrategy($checkingQueueName);
48
    }
49
}
50