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

DelayStrategyResolverTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 57.89 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 22
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetStrategy() 11 11 1
A testGetDefaultStrategy() 11 11 1
A testFailGetDefaultStrategy() 0 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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