| @@ 9-37 (lines=29) @@ | ||
| 6 | use Symfony\Component\Console\Tester\CommandTester; |
|
| 7 | use Tavii\SQSJobQueueBundle\Command\WorkerRunCommand; |
|
| 8 | ||
| 9 | class WorkerRunCommandTest extends \PHPUnit_Framework_TestCase |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @test |
|
| 13 | */ |
|
| 14 | public function コマンドを実行することができる() |
|
| 15 | { |
|
| 16 | $worker = Phake::mock('Tavii\SQSJobQueue\Worker\Worker'); |
|
| 17 | $container = Phake::mock('Symfony\Component\DependencyInjection\Container'); |
|
| 18 | ||
| 19 | Phake::when($container)->get('sqs_job_queue.worker')->thenReturn($worker); |
|
| 20 | ||
| 21 | $application = new Application(); |
|
| 22 | $application->add(new WorkerRunCommand()); |
|
| 23 | ||
| 24 | $command = $application->get('sqs_job_queue:worker-run'); |
|
| 25 | ||
| 26 | $command->setContainer($container); |
|
| 27 | ||
| 28 | $tester = new CommandTester($command); |
|
| 29 | $tester->execute(array( |
|
| 30 | 'command' => $command->getName(), |
|
| 31 | 'queue' => 'test' |
|
| 32 | )); |
|
| 33 | ||
| 34 | Phake::verify($container)->get('sqs_job_queue.worker'); |
|
| 35 | Phake::verify($worker)->run('test'); |
|
| 36 | } |
|
| 37 | } |
|
| @@ 9-37 (lines=29) @@ | ||
| 6 | use Symfony\Component\Console\Tester\CommandTester; |
|
| 7 | use Tavii\SQSJobQueueBundle\Command\WorkerStartCommand; |
|
| 8 | ||
| 9 | class WorkerStartCommandTest extends \PHPUnit_Framework_TestCase |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @test |
|
| 13 | */ |
|
| 14 | public function コマンドを実行することができる() |
|
| 15 | { |
|
| 16 | $worker = Phake::mock('Tavii\SQSJobQueue\Worker\Worker'); |
|
| 17 | $container = Phake::mock('Symfony\Component\DependencyInjection\Container'); |
|
| 18 | ||
| 19 | Phake::when($container)->get('sqs_job_queue.worker')->thenReturn($worker); |
|
| 20 | ||
| 21 | $application = new Application(); |
|
| 22 | $application->add(new WorkerStartCommand()); |
|
| 23 | ||
| 24 | $command = $application->get('sqs_job_queue:worker-start'); |
|
| 25 | ||
| 26 | $command->setContainer($container); |
|
| 27 | ||
| 28 | $tester = new CommandTester($command); |
|
| 29 | $tester->execute(array( |
|
| 30 | 'command' => $command->getName(), |
|
| 31 | 'queue' => 'test', |
|
| 32 | )); |
|
| 33 | ||
| 34 | Phake::verify($container)->get('sqs_job_queue.worker'); |
|
| 35 | Phake::verify($worker)->start('test', 5); |
|
| 36 | } |
|
| 37 | } |
|
| @@ 9-37 (lines=29) @@ | ||
| 6 | use Symfony\Component\Console\Tester\CommandTester; |
|
| 7 | use Tavii\SQSJobQueueBundle\Command\WorkerStopCommand; |
|
| 8 | ||
| 9 | class WorkerStopCommandTest extends \PHPUnit_Framework_TestCase |
|
| 10 | { |
|
| 11 | /** |
|
| 12 | * @test |
|
| 13 | */ |
|
| 14 | public function コマンドを実行することができる() |
|
| 15 | { |
|
| 16 | $worker = Phake::mock('Tavii\SQSJobQueue\Worker\Worker'); |
|
| 17 | $container = Phake::mock('Symfony\Component\DependencyInjection\Container'); |
|
| 18 | ||
| 19 | Phake::when($container)->get('sqs_job_queue.worker')->thenReturn($worker); |
|
| 20 | ||
| 21 | $application = new Application(); |
|
| 22 | $application->add(new WorkerStopCommand()); |
|
| 23 | ||
| 24 | $command = $application->get('sqs_job_queue:worker-stop'); |
|
| 25 | ||
| 26 | $command->setContainer($container); |
|
| 27 | ||
| 28 | $tester = new CommandTester($command); |
|
| 29 | $tester->execute(array( |
|
| 30 | 'command' => $command->getName(), |
|
| 31 | 'queue' => 'test', |
|
| 32 | )); |
|
| 33 | ||
| 34 | Phake::verify($container)->get('sqs_job_queue.worker'); |
|
| 35 | Phake::verify($worker)->stop('test', null, false); |
|
| 36 | } |
|
| 37 | } |
|