Completed
Push — master ( 451f62...fe985e )
by Anton
06:19
created

QueueRequeueCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 50
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testCreate() 0 7 1
A dataExecute() 0 13 1
A testExecute() 0 14 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lamoda\QueueBundle\Tests\Unit\Command;
6
7
use Lamoda\QueueBundle\Command\QueueRequeueCommand;
8
use Lamoda\QueueBundle\Tests\Unit\QueueCommonServicesTrait;
9
use Lamoda\QueueBundle\Tests\Unit\Reflection;
10
use Lamoda\QueueBundle\Tests\Unit\SymfonyMockTrait;
11
use PHPUnit_Framework_TestCase;
12
13
class QueueRequeueCommandTest extends PHPUnit_Framework_TestCase
0 ignored issues
show
Bug introduced by
There is one abstract method getMockBuilder in this class; you could implement it, or declare this class as abstract.
Loading history...
14
{
15
    use QueueCommonServicesTrait;
16
    use SymfonyMockTrait;
17
18
    public function testCreate(): void
19
    {
20
        $requeueService = $this->getMockQueueRequeueService();
21
        $command = new QueueRequeueCommand($requeueService, 1);
22
23
        $this->assertEquals('queue:requeue', $command->getName());
24
    }
25
26
    public function dataExecute(): array
27
    {
28
        return [
29
            [
30
                true,
31
                0,
32
            ],
33
            [
34
                false,
35
                1,
36
            ],
37
        ];
38
    }
39
40
    /**
41
     * @param bool $restored
42
     * @param int  $expected
43
     *
44
     * @throws \Exception
45
     *
46
     * @dataProvider dataExecute
47
     */
48
    public function testExecute(bool $restored, int $expected): void
49
    {
50
        $requeueService = $this->getMockQueueRequeueService(['restoreQueues']);
51
        $requeueService->expects($this->once())
52
            ->method('restoreQueues')
53
            ->willReturn($restored);
54
55
        $command = new QueueRequeueCommand($requeueService, 1);
56
57
        $this->assertEquals(
58
            $expected,
59
            Reflection::callProtectedMethod($command, 'execute', $this->getMockInput(), $this->getMockOutput())
60
        );
61
    }
62
}
63