Code Duplication    Length = 30-30 lines in 2 locations

tests/unit/Strategy/Delay/ArithmeticProgressionStrategyTest.php 1 location

@@ 10-39 (lines=30) @@
7
use Codeception\Test\Unit;
8
use Lamoda\QueueBundle\Strategy\Delay\ArithmeticProgressionStrategy;
9
10
class ArithmeticProgressionStrategyTest extends Unit
11
{
12
    /**
13
     * @param int   $expectedDelay
14
     * @param int   $startIntervalSec
15
     * @param float $multiplier
16
     * @param int   $attempt
17
     *
18
     * @dataProvider dataGenerateDelay
19
     */
20
    public function testGenerateDelay(int $expectedDelay, int $startIntervalSec, float $multiplier, int $attempt): void
21
    {
22
        $strategy = new ArithmeticProgressionStrategy($startIntervalSec, $multiplier);
23
24
        $actualDelayInterval = $strategy->generateInterval($attempt);
25
26
        $this->assertEquals($expectedDelay, $actualDelayInterval->s);
27
    }
28
29
    public function dataGenerateDelay(): array
30
    {
31
        return [
32
            [60, 60, 1600, 1],
33
            [1660, 60, 1600, 2],
34
            [3260, 60, 1600, 3],
35
            [4860, 60, 1600, 4],
36
            'float multiplier' => [6462, 60,  1600.5, 5],
37
        ];
38
    }
39
}
40

tests/unit/Strategy/Delay/GeometricProgressionStrategyTest.php 1 location

@@ 10-39 (lines=30) @@
7
use Codeception\Test\Unit;
8
use Lamoda\QueueBundle\Strategy\Delay\GeometricProgressionStrategy;
9
10
class GeometricProgressionStrategyTest extends Unit
11
{
12
    /**
13
     * @param int   $expectedDelay
14
     * @param int   $startIntervalSec
15
     * @param float $multiplier
16
     * @param int   $attempt
17
     *
18
     * @dataProvider dataGenerateDelay
19
     */
20
    public function testGenerateDelay(int $expectedDelay, int $startIntervalSec, float $multiplier, int $attempt): void
21
    {
22
        $strategy = new GeometricProgressionStrategy($startIntervalSec, $multiplier);
23
24
        $actualDelayInterval = $strategy->generateInterval($attempt);
25
26
        $this->assertEquals($expectedDelay, $actualDelayInterval->s);
27
    }
28
29
    public function dataGenerateDelay(): array
30
    {
31
        return [
32
            [1, 1, 1, 1],
33
            [4, 1, 2, 3],
34
            [4, 2, 2, 2],
35
            [480, 60, 2, 4],
36
            'float multiplier' => [938, 60, 2.5, 4],
37
        ];
38
    }
39
}
40