Completed
Pull Request — master (#2)
by Wachter
05:57
created

RunHandlerCommandTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 1 Features 1
Metric Value
wmc 3
c 1
b 1
f 1
lcom 1
cbo 4
dl 0
loc 42
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testConfigure() 0 7 1
A runProvider() 0 7 1
A testRun() 0 20 1
1
<?php
2
3
namespace Unit\Command;
4
5
use Prophecy\Argument;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Output\OutputInterface;
8
use Task\Handler\RegistryInterface;
9
use Task\TaskBundle\Command\RunHandlerCommand;
10
11
class RunHandlerCommandTest extends \PHPUnit_Framework_TestCase
12
{
13
    public function testConfigure()
14
    {
15
        $scheduler = $this->prophesize(RegistryInterface::class);
16
        $command = new RunHandlerCommand($scheduler->reveal());
17
18
        $this->assertEquals('task:run:handler', $command->getName());
19
    }
20
21
    public function runProvider()
22
    {
23
        return [
24
            ['test-handler', 'test-workload'],
25
            ['test-handler-1', 'test-workload-1'],
26
        ];
27
    }
28
29
    /**
30
     * @dataProvider runProvider
31
     */
32
    public function testRun($handlerName, $workload)
33
    {
34
        $input = $this->prophesize(InputInterface::class);
35
        $output = $this->prophesize(OutputInterface::class);
36
37
        $input->bind(Argument::any())->willReturn(true);
38
        $input->validate()->willReturn(true);
39
        $input->isInteractive()->willReturn(false);
40
        $input->hasArgument('command')->willReturn(false);
41
42
        $input->getArgument('handler')->willReturn($handlerName);
43
        $input->getArgument('workload')->willReturn($workload);
44
45
        $registry = $this->prophesize(RegistryInterface::class);
46
        $command = new RunHandlerCommand($registry->reveal());
47
48
        $command->run($input->reveal(), $output->reveal());
49
50
        $registry->run($handlerName, $workload)->shouldBeCalledTimes(1);
51
    }
52
}
53