Code Duplication    Length = 47-47 lines in 2 locations

Tests/Command/QueueDeleteCommandTest.php 1 location

@@ 9-55 (lines=47) @@
6
use Symfony\Component\Console\Tester\CommandTester;
7
use Tavii\SQSJobQueueBundle\Command\QueueDeleteCommand;
8
9
class QueueDeleteCommandTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @test
13
     */
14
    public function キューを削除するコマンドを実行する()
15
    {
16
        $client = Phake::mock('Aws\Sqs\SqsClient');
17
        $container = Phake::mock('Symfony\Component\DependencyInjection\Container');
18
19
        Phake::when($container)->get('sqs_job_queue.client')->thenReturn($client);
20
        Phake::when($client)->getQueueUrl(array(
21
            'QueueName' => 'test_queue'
22
        ))->thenReturn(array(
23
            'QueueUrl' => '/path/to/url'
24
        ));
25
26
        $application = new Application();
27
        $application->add(new QueueDeleteCommand());
28
29
        $command = $application->get('sqs_job_queue:queue-delete');
30
        $command->setContainer($container);
31
32
        $dialog = $command->getHelper('dialog');
33
        $dialog->setInputStream($this->getInputStream("yes\n"));
34
35
        $tester = new CommandTester($command);
36
        $tester->execute(array(
37
            'command' => $command->getName(),
38
            'queue' => 'test_queue'
39
        ));
40
41
        Phake::verify($container)->get('sqs_job_queue.client');
42
        Phake::verify($client)->deleteQueue(array(
43
            'QueueUrl' => '/path/to/url',
44
        ));
45
    }
46
47
    protected function getInputStream($input)
48
    {
49
        $stream = fopen('php://memory', 'r+', false);
50
        fputs($stream, $input);
51
        rewind($stream);
52
53
        return $stream;
54
    }
55
}
56
57
58

Tests/Command/QueuePurgeCommandTest.php 1 location

@@ 9-55 (lines=47) @@
6
use Symfony\Component\Console\Tester\CommandTester;
7
use Tavii\SQSJobQueueBundle\Command\QueuePurgeCommand;
8
9
class QueuePurgeCommandTest extends \PHPUnit_Framework_TestCase
10
{
11
    /**
12
     * @test
13
     */
14
    public function キューの中身をクリアするコマンドを実行する()
15
    {
16
        $client = Phake::mock('Aws\Sqs\SqsClient');
17
        $container = Phake::mock('Symfony\Component\DependencyInjection\Container');
18
19
        Phake::when($container)->get('sqs_job_queue.client')->thenReturn($client);
20
        Phake::when($client)->getQueueUrl(array(
21
            'QueueName' => 'test_queue'
22
        ))->thenReturn(array(
23
            'QueueUrl' => '/path/to/url'
24
        ));
25
26
        $application = new Application();
27
        $application->add(new QueuePurgeCommand());
28
29
        $command = $application->get('sqs_job_queue:queue-purge');
30
        $command->setContainer($container);
31
32
        $dialog = $command->getHelper('dialog');
33
        $dialog->setInputStream($this->getInputStream("yes\n"));
34
35
        $tester = new CommandTester($command);
36
        $tester->execute(array(
37
            'command' => $command->getName(),
38
            'queue' => 'test_queue'
39
        ));
40
41
        Phake::verify($container)->get('sqs_job_queue.client');
42
        Phake::verify($client)->purgeQueue(array(
43
            'QueueUrl' => '/path/to/url',
44
        ));
45
    }
46
47
    protected function getInputStream($input)
48
    {
49
        $stream = fopen('php://memory', 'r+', false);
50
        fputs($stream, $input);
51
        rewind($stream);
52
53
        return $stream;
54
    }
55
}