Skip to content

Commit 0c7a1ae

Browse files
fixed #4 command names to service definition
1 parent 4525972 commit 0c7a1ae

File tree

8 files changed

+19
-12
lines changed

8 files changed

+19
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# CHANGELOG
2+
3+
* dev-master
4+
* ENHANCEMENT #- Moved command name to service definition

src/Command/RunCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class RunCommand extends Command
1919
*/
2020
private $scheduler;
2121

22-
public function __construct(SchedulerInterface $scheduler)
22+
public function __construct($name, SchedulerInterface $scheduler)
2323
{
24-
parent::__construct('task:run');
24+
parent::__construct($name);
2525

2626
$this->scheduler = $scheduler;
2727
}

src/Command/RunHandlerCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ class RunHandlerCommand extends Command
2121
*/
2222
private $registry;
2323

24-
public function __construct(RegistryInterface $registry)
24+
public function __construct($name, RegistryInterface $registry)
2525
{
26-
parent::__construct('task:run:handler');
26+
parent::__construct($name);
2727

2828
$this->registry = $registry;
2929
}

src/Command/ScheduleTaskCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ class ScheduleTaskCommand extends Command
2020
*/
2121
private $scheduler;
2222

23-
public function __construct(SchedulerInterface $scheduler)
23+
public function __construct($name, SchedulerInterface $scheduler)
2424
{
25-
parent::__construct('task:schedule:task');
25+
parent::__construct($name);
2626

2727
$this->scheduler = $scheduler;
2828
}

src/Resources/config/command.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
55
<services>
66
<service id="task.command.run" class="Task\TaskBundle\Command\RunCommand">
7+
<argument type="string">task:run</argument>
78
<argument type="service" id="task.scheduler"/>
89

910
<tag name="console.command"/>
1011
</service>
1112

1213
<service id="task.command.run.handler" class="Task\TaskBundle\Command\RunHandlerCommand">
14+
<argument type="string">task:run:handler</argument>
1315
<argument type="service" id="task.handler_registry"/>
1416

1517
<tag name="console.command"/>
1618
</service>
1719

1820
<service id="task.command.schedule_task" class="Task\TaskBundle\Command\ScheduleTaskCommand">
21+
<argument type="string">task:schedule:task</argument>
1922
<argument type="service" id="task.scheduler"/>
2023

2124
<tag name="console.command"/>

tests/Unit/Command/RunCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class RunCommandTest extends \PHPUnit_Framework_TestCase
1212
public function testConfigure()
1313
{
1414
$scheduler = $this->prophesize(SchedulerInterface::class);
15-
$command = new RunCommand($scheduler->reveal());
15+
$command = new RunCommand('task:run', $scheduler->reveal());
1616

1717
$this->assertEquals('task:run', $command->getName());
1818
}
@@ -23,7 +23,7 @@ public function testRun()
2323
$output = $this->prophesize(OutputInterface::class);
2424

2525
$scheduler = $this->prophesize(SchedulerInterface::class);
26-
$command = new RunCommand($scheduler->reveal());
26+
$command = new RunCommand('task:run', $scheduler->reveal());
2727

2828
$command->run($input->reveal(), $output->reveal());
2929

tests/Unit/Command/RunHandlerCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class RunHandlerCommandTest extends \PHPUnit_Framework_TestCase
1313
public function testConfigure()
1414
{
1515
$scheduler = $this->prophesize(RegistryInterface::class);
16-
$command = new RunHandlerCommand($scheduler->reveal());
16+
$command = new RunHandlerCommand('task:run:handler', $scheduler->reveal());
1717

1818
$this->assertEquals('task:run:handler', $command->getName());
1919
}
@@ -43,7 +43,7 @@ public function testRun($handlerName, $workload)
4343
$input->getArgument('workload')->willReturn($workload);
4444

4545
$registry = $this->prophesize(RegistryInterface::class);
46-
$command = new RunHandlerCommand($registry->reveal());
46+
$command = new RunHandlerCommand('task:run:handler', $registry->reveal());
4747

4848
$command->run($input->reveal(), $output->reveal());
4949

tests/Unit/Command/ScheduleTaskCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class ScheduleTaskCommandTest extends \PHPUnit_Framework_TestCase
1414
public function testConfigure()
1515
{
1616
$scheduler = $this->prophesize(SchedulerInterface::class);
17-
$command = new ScheduleTaskCommand($scheduler->reveal());
17+
$command = new ScheduleTaskCommand('task:schedule:task', $scheduler->reveal());
1818

1919
$this->assertEquals('task:schedule:task', $command->getName());
2020
$this->assertTrue($command->getDefinition()->hasArgument('handler'));
@@ -48,7 +48,7 @@ public function testRun($handler, $workload)
4848
$input->getArgument('workload')->willReturn($workload);
4949

5050
$scheduler = $this->prophesize(SchedulerInterface::class);
51-
$command = new ScheduleTaskCommand($scheduler->reveal());
51+
$command = new ScheduleTaskCommand('task:schedule:task', $scheduler->reveal());
5252

5353
$scheduler->createTask($handler, $workload)->shouldBeCalledTimes(1)->willReturn($taskBuilder->reveal());
5454

0 commit comments

Comments
 (0)