mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-17 23:13:15 +00:00
Rename task tests, add task start and task stop
This commit is contained in:
38
lib/Alchemy/Phrasea/Command/Task/TaskStart.php
Normal file
38
lib/Alchemy/Phrasea/Command/Task/TaskStart.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2013 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\Task;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
|
class TaskStart extends Command
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct('task-manager:task:start');
|
||||||
|
|
||||||
|
$this
|
||||||
|
->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;
|
||||||
|
}
|
||||||
|
}
|
38
lib/Alchemy/Phrasea/Command/Task/TaskStop.php
Normal file
38
lib/Alchemy/Phrasea/Command/Task/TaskStop.php
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2013 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Alchemy\Phrasea\Command\Task;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
|
||||||
|
class TaskStop extends Command
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct('task-manager:task:stop');
|
||||||
|
|
||||||
|
$this
|
||||||
|
->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;
|
||||||
|
}
|
||||||
|
}
|
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Command\Task;
|
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()
|
public function testRunWithoutProblems()
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ class SchedulerStopTest extends \PhraseanetPHPUnitAbstract
|
|||||||
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
|
|
||||||
$command = new SchedulerStop();
|
$command = new SchedulerPauseTasks();
|
||||||
$command->setContainer(self::$DI['cli']);
|
$command->setContainer(self::$DI['cli']);
|
||||||
$command->execute($input, $output);
|
$command->execute($input, $output);
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Command\Task;
|
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()
|
public function testRunWithoutProblems()
|
||||||
{
|
{
|
||||||
@@ -17,7 +17,7 @@ class SchedulerStartTest extends \PhraseanetPHPUnitAbstract
|
|||||||
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
|
|
||||||
$command = new SchedulerStart();
|
$command = new SchedulerResumeTasks();
|
||||||
$command->setContainer(self::$DI['cli']);
|
$command->setContainer(self::$DI['cli']);
|
||||||
$command->execute($input, $output);
|
$command->execute($input, $output);
|
||||||
}
|
}
|
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Command\Task;
|
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()
|
public function testRunWithoutProblems()
|
||||||
{
|
{
|
||||||
@@ -20,7 +20,7 @@ class TaskManagerCommandTest extends \PhraseanetPHPUnitAbstract
|
|||||||
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
$input = $this->getMock('Symfony\Component\Console\Input\InputInterface');
|
||||||
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
$output = $this->getMock('Symfony\Component\Console\Output\OutputInterface');
|
||||||
|
|
||||||
$command = new TaskManagerCommand();
|
$command = new SchedulerRun();
|
||||||
$command->setContainer(self::$DI['cli']);
|
$command->setContainer(self::$DI['cli']);
|
||||||
$command->execute($input, $output);
|
$command->execute($input, $output);
|
||||||
}
|
}
|
@@ -18,8 +18,8 @@ class TaskListTest extends \PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
$application = new \Symfony\Component\Console\Application();
|
$application = new \Symfony\Component\Console\Application();
|
||||||
$application->add($command);
|
$application->add($command);
|
||||||
|
|
||||||
$setupCommand = $application->find('task:list');
|
$setupCommand = $application->find('task-manager:task:list');
|
||||||
$setupCommand->execute($input, $output);
|
$setupCommand->execute($input, $output);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
32
tests/Alchemy/Tests/Phrasea/Command/Task/TaskStartTest.php
Normal file
32
tests/Alchemy/Tests/Phrasea/Command/Task/TaskStartTest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Command\Task;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Task\TaskStart;
|
||||||
|
use Entities\Task;
|
||||||
|
|
||||||
|
class TaskStartTest extends \PhraseanetPHPUnitAbstract
|
||||||
|
{
|
||||||
|
public function testRunWithoutProblems()
|
||||||
|
{
|
||||||
|
$task = new Task();
|
||||||
|
$task
|
||||||
|
->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);
|
||||||
|
}
|
||||||
|
}
|
32
tests/Alchemy/Tests/Phrasea/Command/Task/TaskStopTest.php
Normal file
32
tests/Alchemy/Tests/Phrasea/Command/Task/TaskStopTest.php
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Command\Task;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Command\Task\TaskStop;
|
||||||
|
use Entities\Task;
|
||||||
|
|
||||||
|
class TaskStopTest extends \PhraseanetPHPUnitAbstract
|
||||||
|
{
|
||||||
|
public function testRunWithoutProblems()
|
||||||
|
{
|
||||||
|
$task = new Task();
|
||||||
|
$task
|
||||||
|
->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);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user