Completed
Push — master ( 03ffe6...2c1c5a )
by Will
11s
created

ArrayIntegrationTest::testReceiveWithNoMessages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of graze/queue.
5
 *
6
 * Copyright (c) 2015 Nature Delivered Ltd. <https://www.graze.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://github.com/graze/queue/blob/master/LICENSE MIT
12
 *
13
 * @link    https://github.com/graze/queue
14
 */
15
16
namespace Graze\Queue;
17
18
use Graze\Queue\Adapter\ArrayAdapter;
19
use Graze\Queue\Message\MessageFactory;
20
use Graze\Queue\Message\MessageInterface;
21
use PHPUnit_Framework_TestCase as TestCase;
22
23
class ArrayIntegrationTest extends TestCase
24
{
25
    /** @var MessageInterface[] */
26
    private $messages;
27
    /** @var Client */
28
    private $client;
29
30
    public function setUp()
31
    {
32
        $factory = new MessageFactory();
33
34
        $this->messages = [
35
            $factory->createMessage('foo'),
36
            $factory->createMessage('bar'),
37
            $factory->createMessage('baz'),
38
        ];
39
40
        $this->client = new Client(new ArrayAdapter($this->messages));
41
    }
42
43 View Code Duplication
    public function testReceive()
0 ignored issues
show
Duplication introduced by
This method 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...
44
    {
45
        $msgs = [];
46
        $this->client->receive(function ($msg) use (&$msgs) {
47
            $msgs[] = $msg;
48
        }, 100);
49
50
        assertThat($msgs, is(identicalTo($this->messages)));
51
    }
52
53 View Code Duplication
    public function testReceiveWithPolling()
0 ignored issues
show
Duplication introduced by
This method 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...
54
    {
55
        $msgs = [];
56
        $this->client->receive(function ($msg) use (&$msgs) {
57
            $msgs[] = $msg;
58
        }, null);
59
60
        assertThat($msgs, is(identicalTo($this->messages)));
61
    }
62
63 View Code Duplication
    public function testReceiveWithNoMessages()
0 ignored issues
show
Duplication introduced by
This method 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...
64
    {
65
        $client = new Client(new ArrayAdapter());
66
67
        $msgs = [];
68
        $client->receive(function ($msg) use (&$msgs) {
69
            $msgs[] = $msg;
70
        }, null);
71
72
        assertThat($msgs, is(emptyArray()));
73
    }
74
75 View Code Duplication
    public function testReceiveWithLimitAndNoMessages()
0 ignored issues
show
Duplication introduced by
This method 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...
76
    {
77
        $client = new Client(new ArrayAdapter());
78
79
        $msgs = [];
80
        $client->receive(function ($msg) use (&$msgs) {
81
            $msgs[] = $msg;
82
        }, 10);
83
84
        assertThat($msgs, is(emptyArray()));
85
    }
86
87
    public function testSend()
88
    {
89
        $this->client->send([$this->client->create('foo')]);
90
    }
91
92 View Code Duplication
    public function testPurge()
0 ignored issues
show
Duplication introduced by
This method 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...
93
    {
94
        $this->client->purge();
95
96
        $msgs = [];
97
        $this->client->receive(function ($msg) use (&$msgs) {
98
            $msgs[] = $msg;
99
        }, null);
100
101
        assertThat($msgs, is(emptyArray()));
102
    }
103
104 View Code Duplication
    public function testDelete()
0 ignored issues
show
Duplication introduced by
This method 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...
105
    {
106
        $this->client->delete();
107
108
        $msgs = [];
109
        $this->client->receive(function ($msg) use (&$msgs) {
110
            $msgs[] = $msg;
111
        }, null);
112
113
        assertThat($msgs, is(emptyArray()));
114
    }
115
}
116