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

tests/unit/Command/QueueRequeueCommandTest.php (1 issue)

Labels
Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

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
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