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