QueueTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 6
dl 0
loc 85
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B receiveする際にKernelOptionを渡すことができる() 0 29 1
A queueに登録することが出来る() 0 18 1
B 削除を行う事ができる() 0 24 1
1
<?php
2
namespace Tavii\SQSJobQueueBundle;
3
4
use Phake;
5
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
6
use Tavii\SQSJobQueue\Job\booelan;
7
use Tavii\SQSJobQueue\Message\Message;
8
use Tavii\SQSJobQueue\Queue\QueueName;
9
10
class QueueTest extends \PHPUnit_Framework_TestCase
11
{
12
    /**
13
     * @test
14
     */
15
    public function receiveする際にKernelOptionを渡すことができる()
16
    {
17
        $name = "test_queue";
18
        $queueName = new QueueName($name);
19
        $kernelOptions = array(
20
            'kernel.root_dir' => '.',
21
            'kernel.environment' => 'test',
22
            'kernel.debug' => true,
23
        );
24
25
        $job = Phake::mock('Tavii\SQSJobQueueBundle\ContainerAwareJob');
26
        $message = Phake::mock('Tavii\SQSJobQueue\Message\Message');
27
        $baseQueue = Phake::mock('Tavii\SQSJobQueue\Queue\Queue');
28
        $dispatcher = Phake::mock(EventDispatcherInterface::class);
29
30
        Phake::when($baseQueue)->receive($queueName)
31
            ->thenReturn($message);
32
        Phake::when($message)->getJob()
33
            ->thenReturn($job);
34
35
        $queue = new Queue($baseQueue, $dispatcher, $kernelOptions);
0 ignored issues
show
Documentation introduced by
$baseQueue is of type object<Phake_IMock>, but the function expects a object<Tavii\SQSJobQueue\Queue\QueueInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$dispatcher is of type object<Phake_IMock>, but the function expects a object<Symfony\Component...entDispatcherInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
36
        $queue->receive($queueName);
37
38
39
        Phake::verify($baseQueue)->receive($queueName);
40
        Phake::verify($message)->getJob();
41
        Phake::verify($job)->setKernelOptions($kernelOptions);
42
43
    }
44
45
    /**
46
     * @test
47
     */
48
    public function queueに登録することが出来る()
49
    {
50
        $kernelOptions = array(
51
            'kernel.root_dir' => '.',
52
            'kernel.environment' => 'test',
53
            'kernel.debug' => true,
54
        );
55
56
        $baseQueue = Phake::mock('Tavii\SQSJobQueue\Queue\Queue');
57
        $dispatcher = Phake::mock(EventDispatcherInterface::class);
58
59
        $queue = new Queue($baseQueue, $dispatcher, $kernelOptions);
0 ignored issues
show
Documentation introduced by
$baseQueue is of type object<Phake_IMock>, but the function expects a object<Tavii\SQSJobQueue\Queue\QueueInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$dispatcher is of type object<Phake_IMock>, but the function expects a object<Symfony\Component...entDispatcherInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
60
61
        $job = new DummyContainerAwareJob();
62
        $queue->send($job);
63
64
        Phake::verify($baseQueue)->send($job);
65
    }
66
67
    /**
68
     * @test
69
     */
70
    public function 削除を行う事ができる()
71
    {
72
        $kernelOptions = array(
73
            'kernel.root_dir' => '.',
74
            'kernel.environment' => 'test',
75
            'kernel.debug' => true,
76
        );
77
        $dispatcher = Phake::mock(EventDispatcherInterface::class);
78
79
80
        $baseQueue = Phake::mock('Tavii\SQSJobQueue\Queue\Queue');
81
        $queue = new Queue($baseQueue, $dispatcher, $kernelOptions);
0 ignored issues
show
Documentation introduced by
$baseQueue is of type object<Phake_IMock>, but the function expects a object<Tavii\SQSJobQueue\Queue\QueueInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
Documentation introduced by
$dispatcher is of type object<Phake_IMock>, but the function expects a object<Symfony\Component...entDispatcherInterface>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
82
83
        $job = new DummyContainerAwareJob();
84
        $message = new Message(array(),$job,'test.com');
85
86
        Phake::when($baseQueue)->delete($message)
87
            ->thenReturn(true);
88
89
        $job = new DummyContainerAwareJob();
0 ignored issues
show
Unused Code introduced by
$job is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
90
        $queue->delete($message);
91
92
        Phake::verify($baseQueue)->delete($message);
93
    }
94
}
95
96
class DummyContainerAwareJob extends ContainerAwareJob
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
97
{
98
    protected $name = 'dummy_container_aware_job';
99
100
    /**
101
     * @return booelan
102
     */
103
    protected function run()
104
    {
105
106
    }
107
108
}