QueueDeleteCommandTest::キューを削除するコマンドを実行する()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 21

Duplication

Lines 32
Ratio 100 %

Importance

Changes 0
Metric Value
dl 32
loc 32
rs 8.8571
c 0
b 0
f 0
cc 1
eloc 21
nc 1
nop 0
1
<?php
2
namespace Tavii\SQSJobQueueBundle\Tests\Command;
3
4
use Phake;
5
use SebastianBergmann\PHPCOV\Application;
6
use Symfony\Component\Console\Tester\CommandTester;
7
use Tavii\SQSJobQueueBundle\Command\QueueDeleteCommand;
8
9 View Code Duplication
class QueueDeleteCommandTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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