From 046429cc4baf48bbd7566b2e7837e05dd8b8fa3f Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Tue, 29 Oct 2013 14:26:48 +0100 Subject: [PATCH] Rename task tests, add task start and task stop --- .../Phrasea/Command/Task/TaskStart.php | 38 +++++++++++++++++++ lib/Alchemy/Phrasea/Command/Task/TaskStop.php | 38 +++++++++++++++++++ ...lerStopTest.php => SchedulerPauseTest.php} | 6 +-- ...rStartTest.php => SchedulerResumeTest.php} | 6 +-- ...erCommandTest.php => SchedulerRunTest.php} | 6 +-- .../Phrasea/Command/Task/TaskListTest.php | 4 +- .../Phrasea/Command/Task/TaskStartTest.php | 32 ++++++++++++++++ .../Phrasea/Command/Task/TaskStopTest.php | 32 ++++++++++++++++ 8 files changed, 151 insertions(+), 11 deletions(-) create mode 100644 lib/Alchemy/Phrasea/Command/Task/TaskStart.php create mode 100644 lib/Alchemy/Phrasea/Command/Task/TaskStop.php rename tests/Alchemy/Tests/Phrasea/Command/Task/{SchedulerStopTest.php => SchedulerPauseTest.php} (80%) rename tests/Alchemy/Tests/Phrasea/Command/Task/{SchedulerStartTest.php => SchedulerResumeTest.php} (80%) rename tests/Alchemy/Tests/Phrasea/Command/Task/{TaskManagerCommandTest.php => SchedulerRunTest.php} (84%) create mode 100644 tests/Alchemy/Tests/Phrasea/Command/Task/TaskStartTest.php create mode 100644 tests/Alchemy/Tests/Phrasea/Command/Task/TaskStopTest.php diff --git a/lib/Alchemy/Phrasea/Command/Task/TaskStart.php b/lib/Alchemy/Phrasea/Command/Task/TaskStart.php new file mode 100644 index 0000000000..a1495bb1a8 --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Task/TaskStart.php @@ -0,0 +1,38 @@ +addArgument('task_id', InputArgument::REQUIRED, 'The task_id to start') + ->setDescription('Starts a task'); + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + $task = $this->container['converter.task']->convert($input->getArgument('task_id')); + $this->container['manipulator.task']->start($task); + + return 0; + } +} diff --git a/lib/Alchemy/Phrasea/Command/Task/TaskStop.php b/lib/Alchemy/Phrasea/Command/Task/TaskStop.php new file mode 100644 index 0000000000..694c335de8 --- /dev/null +++ b/lib/Alchemy/Phrasea/Command/Task/TaskStop.php @@ -0,0 +1,38 @@ +addArgument('task_id', InputArgument::REQUIRED, 'The task_id to stop') + ->setDescription('Stops a task'); + } + + protected function doExecute(InputInterface $input, OutputInterface $output) + { + $task = $this->container['converter.task']->convert($input->getArgument('task_id')); + $this->container['manipulator.task']->stop($task); + + return 0; + } +} diff --git a/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerStopTest.php b/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerPauseTest.php similarity index 80% rename from tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerStopTest.php rename to tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerPauseTest.php index b57e3a4025..81b34c6b33 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerStopTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerPauseTest.php @@ -2,9 +2,9 @@ namespace Alchemy\Tests\Phrasea\Command\Task; -use Alchemy\Phrasea\Command\Task\SchedulerStop; +use Alchemy\Phrasea\Command\Task\SchedulerPauseTasks; -class SchedulerStopTest extends \PhraseanetPHPUnitAbstract +class SchedulerPauseTasksTest extends \PhraseanetPHPUnitAbstract { public function testRunWithoutProblems() { @@ -17,7 +17,7 @@ class SchedulerStopTest extends \PhraseanetPHPUnitAbstract $input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $command = new SchedulerStop(); + $command = new SchedulerPauseTasks(); $command->setContainer(self::$DI['cli']); $command->execute($input, $output); } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerStartTest.php b/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerResumeTest.php similarity index 80% rename from tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerStartTest.php rename to tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerResumeTest.php index ef9e66a76c..78249a545f 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerStartTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerResumeTest.php @@ -2,9 +2,9 @@ namespace Alchemy\Tests\Phrasea\Command\Task; -use Alchemy\Phrasea\Command\Task\SchedulerStart; +use Alchemy\Phrasea\Command\Task\SchedulerResumeTasks; -class SchedulerStartTest extends \PhraseanetPHPUnitAbstract +class SchedulerResumeTasksTest extends \PhraseanetPHPUnitAbstract { public function testRunWithoutProblems() { @@ -17,7 +17,7 @@ class SchedulerStartTest extends \PhraseanetPHPUnitAbstract $input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $command = new SchedulerStart(); + $command = new SchedulerResumeTasks(); $command->setContainer(self::$DI['cli']); $command->execute($input, $output); } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Task/TaskManagerCommandTest.php b/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerRunTest.php similarity index 84% rename from tests/Alchemy/Tests/Phrasea/Command/Task/TaskManagerCommandTest.php rename to tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerRunTest.php index 09a1b47b61..188552c32a 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Task/TaskManagerCommandTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Task/SchedulerRunTest.php @@ -2,9 +2,9 @@ namespace Alchemy\Tests\Phrasea\Command\Task; -use Alchemy\Phrasea\Command\Task\TaskManagerCommand; +use Alchemy\Phrasea\Command\Task\SchedulerRun; -class TaskManagerCommandTest extends \PhraseanetPHPUnitAbstract +class SchedulerRunTest extends \PhraseanetPHPUnitAbstract { public function testRunWithoutProblems() { @@ -20,7 +20,7 @@ class TaskManagerCommandTest extends \PhraseanetPHPUnitAbstract $input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); - $command = new TaskManagerCommand(); + $command = new SchedulerRun(); $command->setContainer(self::$DI['cli']); $command->execute($input, $output); } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Task/TaskListTest.php b/tests/Alchemy/Tests/Phrasea/Command/Task/TaskListTest.php index 3bf72fb37f..9dcb202ba1 100644 --- a/tests/Alchemy/Tests/Phrasea/Command/Task/TaskListTest.php +++ b/tests/Alchemy/Tests/Phrasea/Command/Task/TaskListTest.php @@ -18,8 +18,8 @@ class TaskListTest extends \PhraseanetPHPUnitAbstract $application = new \Symfony\Component\Console\Application(); $application->add($command); - - $setupCommand = $application->find('task:list'); + + $setupCommand = $application->find('task-manager:task:list'); $setupCommand->execute($input, $output); } } diff --git a/tests/Alchemy/Tests/Phrasea/Command/Task/TaskStartTest.php b/tests/Alchemy/Tests/Phrasea/Command/Task/TaskStartTest.php new file mode 100644 index 0000000000..1620de5dcd --- /dev/null +++ b/tests/Alchemy/Tests/Phrasea/Command/Task/TaskStartTest.php @@ -0,0 +1,32 @@ +setName('Task') + ->setJobId('Null'); + + self::$DI['cli']['EM']->persist($task); + self::$DI['cli']['EM']->flush(); + + $input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); + $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + + $input->expects($this->any()) + ->method('getArgument') + ->with('task_id') + ->will($this->returnValue($task->getId())); + + $command = new TaskStart(); + $command->setContainer(self::$DI['cli']); + $command->execute($input, $output); + } +} diff --git a/tests/Alchemy/Tests/Phrasea/Command/Task/TaskStopTest.php b/tests/Alchemy/Tests/Phrasea/Command/Task/TaskStopTest.php new file mode 100644 index 0000000000..7ecea98864 --- /dev/null +++ b/tests/Alchemy/Tests/Phrasea/Command/Task/TaskStopTest.php @@ -0,0 +1,32 @@ +setName('Task') + ->setJobId('Null'); + + self::$DI['cli']['EM']->persist($task); + self::$DI['cli']['EM']->flush(); + + $input = $this->getMock('Symfony\Component\Console\Input\InputInterface'); + $output = $this->getMock('Symfony\Component\Console\Output\OutputInterface'); + + $input->expects($this->any()) + ->method('getArgument') + ->with('task_id') + ->will($this->returnValue($task->getId())); + + $command = new TaskStop(); + $command->setContainer(self::$DI['cli']); + $command->execute($input, $output); + } +}