Completed
Push — master ( b6f93c...d2ae44 )
by Thomas Mauro
03:48
created

QueueTest::testDeclareQueueWithNoDeclare()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 20
rs 9.4285
cc 1
eloc 13
nc 1
nop 0
1
<?php
2
3
namespace AMQPAL\Adapter\AMQP;
4
5
use AMQPAL\Adapter\Message;
6
use AMQPAL\Options;
7
use Prophecy\Argument;
8
9
class QueueTest extends \PHPUnit_Framework_TestCase
10
{
11
12
    public function testSetResource()
13
    {
14
        $resource = $this->prophesize(\AMQPQueue::class);
15
16
        $exchange = new Queue();
17
        $exchange->setResource($resource->reveal());
18
19
        static::assertSame($resource->reveal(), $exchange->getResource());
20
    }
21
22
    public function testGetDefaultMessageMapper()
23
    {
24
        $exchange = new Queue();
25
26
        static::assertInstanceOf(MessageMapper::class, $exchange->getMessageMapper());
27
    }
28
29
    public function testSetOptions()
30
    {
31
        $options = $this->getDefaultOptionsProphet();
32
        $resource = $this->prophesize(\AMQPQueue::class);
33
34
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
35
            ->shouldBeCalled();
36
        $resource->setName('queueName')->shouldBeCalled();
37
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
38
39
        $queue = new Queue();
40
        $queue->setResource($resource->reveal());
41
42
        static::assertSame($queue, $queue->setOptions($options->reveal()));
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
43
        static::assertSame($options->reveal(), $queue->getOptions());
44
    }
45
46
    public function testDeclareQueue()
47
    {
48
        $options = $this->getDefaultOptionsProphet();
49
        $resource = $this->prophesize(\AMQPQueue::class);
50
51
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
52
            ->shouldBeCalled();
53
        $resource->setName('queueName')->shouldBeCalled();
54
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
55
56
        $resource->declareQueue()->shouldBeCalled();
57
58
        $exchange = new Queue();
59
        $exchange->setResource($resource->reveal());
60
        $exchange->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
61
62
        static::assertSame($exchange, $exchange->declareQueue());
63
    }
64
65
    /**
66
     * @dataProvider deleteProvider()
67
     */
68
    public function testDelete($ifUnused, $ifEmpty, $noWait, $flags)
69
    {
70
        $options = $this->getDefaultOptionsProphet();
71
        $resource = $this->prophesize(\AMQPQueue::class);
72
73
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
74
            ->shouldBeCalled();
75
        $resource->setName('queueName')->shouldBeCalled();
76
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
77
78
        $resource->delete($flags)->shouldBeCalled();
79
80
        $exchange = new Queue();
81
        $exchange->setResource($resource->reveal());
82
        $exchange->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
83
84
        static::assertSame($exchange, $exchange->delete($ifUnused, $ifEmpty, $noWait));
85
    }
86
87
    public function testBind()
88
    {
89
        $arguments = ['arg2' => 'value2'];
90
91
        $options = $this->getDefaultOptionsProphet();
92
        $resource = $this->prophesize(\AMQPQueue::class);
93
94
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
95
            ->shouldBeCalled();
96
        $resource->setName('queueName')->shouldBeCalled();
97
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
98
99
        $resource->bind('exchangeName', 'routingKey', $arguments)->shouldBeCalled();
100
101
        $queue = new Queue();
102
        $queue->setResource($resource->reveal());
103
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
104
105
        static::assertSame($queue, $queue->bind('exchangeName', 'routingKey', false, $arguments));
106
    }
107
108
    public function testUnbind()
109
    {
110
        $arguments = ['arg2' => 'value2'];
111
112
        $options = $this->getDefaultOptionsProphet();
113
        $resource = $this->prophesize(\AMQPQueue::class);
114
115
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
116
            ->shouldBeCalled();
117
        $resource->setName('queueName')->shouldBeCalled();
118
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
119
120
        $resource->unbind('exchangeName', 'routingKey', $arguments)->shouldBeCalled();
121
122
        $queue = new Queue();
123
        $queue->setResource($resource->reveal());
124
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
125
126
        static::assertSame($queue, $queue->unbind('exchangeName', 'routingKey', $arguments));
127
    }
128
129
    public function testAck()
130
    {
131
        $options = $this->getDefaultOptionsProphet();
132
        $resource = $this->prophesize(\AMQPQueue::class);
133
134
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
135
            ->shouldBeCalled();
136
        $resource->setName('queueName')->shouldBeCalled();
137
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
138
139
        $resource->ack('deliveryTag', AMQP_NOPARAM)->shouldBeCalled();
140
141
        $queue = new Queue();
142
        $queue->setResource($resource->reveal());
143
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
144
145
        static::assertSame($queue, $queue->ack('deliveryTag'));
146
    }
147
148
    public function testAckMultiple()
149
    {
150
        $options = $this->getDefaultOptionsProphet();
151
        $resource = $this->prophesize(\AMQPQueue::class);
152
153
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
154
            ->shouldBeCalled();
155
        $resource->setName('queueName')->shouldBeCalled();
156
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
157
158
        $resource->ack('deliveryTag', AMQP_MULTIPLE)->shouldBeCalled();
159
160
        $queue = new Queue();
161
        $queue->setResource($resource->reveal());
162
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
163
164
        static::assertSame($queue, $queue->ack('deliveryTag', true));
165
    }
166
167
    public function testNack()
168
    {
169
        $options = $this->getDefaultOptionsProphet();
170
        $resource = $this->prophesize(\AMQPQueue::class);
171
172
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
173
            ->shouldBeCalled();
174
        $resource->setName('queueName')->shouldBeCalled();
175
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
176
177
        $resource->nack('deliveryTag', AMQP_NOPARAM)->shouldBeCalled();
178
179
        $queue = new Queue();
180
        $queue->setResource($resource->reveal());
181
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
182
183
        static::assertSame($queue, $queue->nack('deliveryTag'));
184
    }
185
186
    public function testNackRequeue()
187
    {
188
        $options = $this->getDefaultOptionsProphet();
189
        $resource = $this->prophesize(\AMQPQueue::class);
190
191
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
192
            ->shouldBeCalled();
193
        $resource->setName('queueName')->shouldBeCalled();
194
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
195
196
        $resource->nack('deliveryTag', AMQP_REQUEUE)->shouldBeCalled();
197
198
        $queue = new Queue();
199
        $queue->setResource($resource->reveal());
200
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
201
202
        static::assertSame($queue, $queue->nack('deliveryTag', true));
203
    }
204
205
    public function testNackMultiple()
206
    {
207
        $options = $this->getDefaultOptionsProphet();
208
        $resource = $this->prophesize(\AMQPQueue::class);
209
210
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
211
            ->shouldBeCalled();
212
        $resource->setName('queueName')->shouldBeCalled();
213
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
214
215
        $resource->nack('deliveryTag', AMQP_MULTIPLE)->shouldBeCalled();
216
217
        $queue = new Queue();
218
        $queue->setResource($resource->reveal());
219
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
220
221
        static::assertSame($queue, $queue->nack('deliveryTag', false, true));
222
    }
223
224
    public function testNackRequeueMultiple()
225
    {
226
        $options = $this->getDefaultOptionsProphet();
227
        $resource = $this->prophesize(\AMQPQueue::class);
228
229
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
230
            ->shouldBeCalled();
231
        $resource->setName('queueName')->shouldBeCalled();
232
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
233
234
        $resource->nack('deliveryTag', AMQP_REQUEUE | AMQP_MULTIPLE)->shouldBeCalled();
235
236
        $queue = new Queue();
237
        $queue->setResource($resource->reveal());
238
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
239
240
        static::assertSame($queue, $queue->nack('deliveryTag', true, true));
241
    }
242
243
    public function testReject()
244
    {
245
        $options = $this->getDefaultOptionsProphet();
246
        $resource = $this->prophesize(\AMQPQueue::class);
247
248
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
249
            ->shouldBeCalled();
250
        $resource->setName('queueName')->shouldBeCalled();
251
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
252
253
        $resource->reject('deliveryTag', AMQP_NOPARAM)->shouldBeCalled();
254
255
        $queue = new Queue();
256
        $queue->setResource($resource->reveal());
257
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
258
259
        static::assertSame($queue, $queue->reject('deliveryTag'));
260
    }
261
262
    public function testRejectRequeue()
263
    {
264
        $options = $this->getDefaultOptionsProphet();
265
        $resource = $this->prophesize(\AMQPQueue::class);
266
267
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
268
            ->shouldBeCalled();
269
        $resource->setName('queueName')->shouldBeCalled();
270
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
271
272
        $resource->reject('deliveryTag', AMQP_REQUEUE)->shouldBeCalled();
273
274
        $queue = new Queue();
275
        $queue->setResource($resource->reveal());
276
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
277
278
        static::assertSame($queue, $queue->reject('deliveryTag', true));
279
    }
280
281
    public function testPurge()
282
    {
283
        $options = $this->getDefaultOptionsProphet();
284
        $resource = $this->prophesize(\AMQPQueue::class);
285
286
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
287
            ->shouldBeCalled();
288
        $resource->setName('queueName')->shouldBeCalled();
289
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
290
291
        $resource->purge()->shouldBeCalled();
292
293
        $queue = new Queue();
294
        $queue->setResource($resource->reveal());
295
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
296
297
        static::assertSame($queue, $queue->purge());
298
    }
299
300
    public function testCancel()
301
    {
302
        $options = $this->getDefaultOptionsProphet();
303
        $resource = $this->prophesize(\AMQPQueue::class);
304
305
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
306
            ->shouldBeCalled();
307
        $resource->setName('queueName')->shouldBeCalled();
308
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
309
310
        $resource->cancel('')->shouldBeCalled();
311
312
        $queue = new Queue();
313
        $queue->setResource($resource->reveal());
314
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
315
316
        static::assertSame($queue, $queue->cancel(null));
317
    }
318
319
    public function testGet()
320
    {
321
        $options = $this->getDefaultOptionsProphet();
322
        $resource = $this->prophesize(\AMQPQueue::class);
323
        $messageMapper = $this->prophesize(MessageMapper::class);
324
325
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
326
            ->shouldBeCalled();
327
        $resource->setName('queueName')->shouldBeCalled();
328
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
329
330
        $resource->get(AMQP_NOPARAM)->shouldBeCalled();
331
332
        $queue = new Queue();
333
        $queue->setResource($resource->reveal());
334
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
335
        $queue->setMessageMapper($messageMapper->reveal());
336
337
        static::assertNull($queue->get());
338
    }
339
340
    public function testGetWithAutoAck()
341
    {
342
        $options = $this->getDefaultOptionsProphet();
343
        $resource = $this->prophesize(\AMQPQueue::class);
344
        $messageMapper = $this->prophesize(MessageMapper::class);
345
346
        $messageMapper->toMessage(Argument::any())->shouldNotBeCalled();
347
348
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
349
            ->shouldBeCalled();
350
        $resource->setName('queueName')->shouldBeCalled();
351
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
352
353
        $resource->get(AMQP_AUTOACK)->shouldBeCalled();
354
355
        $queue = new Queue();
356
        $queue->setResource($resource->reveal());
357
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
358
        $queue->setMessageMapper($messageMapper->reveal());
359
360
        static::assertNull($queue->get(true));
361
    }
362
363
    public function testGetWithAutoAckAndMessage()
364
    {
365
        $options = $this->getDefaultOptionsProphet();
366
        $resource = $this->prophesize(\AMQPQueue::class);
367
        $message = $this->prophesize(Message::class);
368
        $libMessage = $this->prophesize(\AMQPEnvelope::class);
369
        $messageMapper = $this->prophesize(MessageMapper::class);
370
371
        $messageMapper->toMessage($libMessage->reveal())->shouldBeCalled()->willReturn($message->reveal());
372
373
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
374
            ->shouldBeCalled();
375
        $resource->setName('queueName')->shouldBeCalled();
376
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
377
378
        $resource->get(AMQP_AUTOACK)
379
            ->shouldBeCalled()
380
            ->willReturn($libMessage->reveal());
381
382
        $queue = new Queue();
383
        $queue->setResource($resource->reveal());
384
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
385
        $queue->setMessageMapper($messageMapper->reveal());
386
387
        static::assertSame($message->reveal(), $queue->get(true));
388
    }
389
390
    public function testConsume()
391
    {
392
        $options = $this->getDefaultOptionsProphet();
393
        $resource = $this->prophesize(\AMQPQueue::class);
394
        $libMessage = $this->prophesize(\AMQPEnvelope::class);
395
        $messageMapper = $this->prophesize(MessageMapper::class);
396
397
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
398
            ->shouldBeCalled();
399
        $resource->setName('queueName')->shouldBeCalled();
400
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
401
402
        $resource->consume(Argument::type(ConsumerCallback::class), AMQP_NOPARAM, 'consumerTag')
403
            ->shouldBeCalled()
404
            ->willReturn($libMessage->reveal());
405
406
        $queue = new Queue();
407
        $queue->setResource($resource->reveal());
408
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
409
        $queue->setMessageMapper($messageMapper->reveal());
410
411
        $callback = function () {
412
            
413
        };
414
415
        $ret = $queue->consume('consumerTag', false, false, false, false, $callback);
416
417
        static::assertSame($queue, $ret);
418
    }
419
420
    /**
421
     * @dataProvider consumeProviderWithFlags
422
     */
423
    public function testConsumeWithFlags(array $consumeArgs, $flags, $consumerTag)
424
    {
425
        $options = $this->getDefaultOptionsProphet();
426
        $resource = $this->prophesize(\AMQPQueue::class);
427
        $libMessage = $this->prophesize(\AMQPEnvelope::class);
428
        $messageMapper = $this->prophesize(MessageMapper::class);
429
430
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE | AMQP_NOWAIT)
431
            ->shouldBeCalled();
432
        $resource->setName('queueName')->shouldBeCalled();
433
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
434
435
        $resource->consume(null, $flags, $consumerTag)
436
            ->shouldBeCalled()
437
            ->willReturn($libMessage->reveal());
438
439
        $queue = new Queue();
440
        $queue->setResource($resource->reveal());
441
        $queue->setOptions($options->reveal());
0 ignored issues
show
Bug introduced by
The method reveal does only exist in Prophecy\Prophecy\ObjectProphecy, but not in AMQPAL\Options\QueueOptions.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
442
        $queue->setMessageMapper($messageMapper->reveal());
443
444
        $ret = call_user_func_array([$queue, 'consume'], $consumeArgs);
445
        static::assertSame($queue, $ret);
446
    }
447
448
    public function consumeProviderWithFlags()
449
    {
450
        return [
451
            [
452
                [null, false, false, false, null],
453
                AMQP_NOPARAM, null
454
            ],
455
            [
456
                [null, true, false, false, false, null],
457
                AMQP_NOLOCAL, null
458
            ],
459
            [
460
                [null, false, true, false, false, null],
461
                AMQP_AUTOACK, null
462
            ],
463
            [
464
                [null, false, false, true, false, null],
465
                AMQP_EXCLUSIVE, null
466
            ],
467
            [
468
                [null, false, false, false, true, null],
469
                AMQP_NOWAIT, null
470
            ],
471
            [
472
                [null, true, true, true, true, null],
473
                AMQP_NOLOCAL | AMQP_AUTOACK | AMQP_EXCLUSIVE | AMQP_NOWAIT, null
474
            ]
475
        ];
476
    }
477
478
    public function testSetAndGetChannel()
479
    {
480
        $channel = $this->prophesize(Channel::class);
481
482
        $exchange = new Queue();
483
        static::assertSame($exchange, $exchange->setChannel($channel->reveal()));
484
        static::assertSame($channel->reveal(), $exchange->getChannel());
485
    }
486
487
    public function testGetConnection()
488
    {
489
        $channel = $this->prophesize(Channel::class);
490
        $connection = $this->prophesize(Connection::class);
491
492
        $channel->getConnection()->willReturn($connection);
493
494
        $exchange = new Queue();
495
        static::assertSame($exchange, $exchange->setChannel($channel->reveal()));
496
        static::assertSame($connection->reveal(), $exchange->getConnection());
497
    }
498
499
    public function deleteProvider()
500
    {
501
        return [
502
            [true, true, true, AMQP_NOPARAM | AMQP_IFUNUSED | AMQP_IFEMPTY | AMQP_NOWAIT],
503
            [true, true, false, AMQP_NOPARAM | AMQP_IFUNUSED | AMQP_IFEMPTY],
504
            [true, false, true, AMQP_NOPARAM | AMQP_IFUNUSED | AMQP_NOWAIT],
505
            [true, false, false, AMQP_NOPARAM | AMQP_IFUNUSED],
506
            [false, true, true, AMQP_NOPARAM | AMQP_IFEMPTY | AMQP_NOWAIT],
507
            [false, true, false, AMQP_NOPARAM | AMQP_IFEMPTY],
508
            [false, false, true, AMQP_NOPARAM | AMQP_NOWAIT],
509
            [false, false, false, AMQP_NOPARAM],
510
        ];
511
    }
512
513
    /**
514
     * @return Options\QueueOptions|\Prophecy\Prophecy\ObjectProphecy
515
     */
516
    protected function getDefaultOptionsProphet()
517
    {
518
        /** @var Options\QueueOptions|\Prophecy\Prophecy\ObjectProphecy $options */
519
        $options = $this->prophesize(Options\QueueOptions::class);
520
521
        $options->isDurable()->willReturn(true);
0 ignored issues
show
Bug introduced by
The method isDurable does only exist in AMQPAL\Options\QueueOptions, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
522
        $options->isPassive()->willReturn(true);
0 ignored issues
show
Bug introduced by
The method isPassive does only exist in AMQPAL\Options\QueueOptions, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
523
        $options->isAutoDelete()->willReturn(true);
0 ignored issues
show
Bug introduced by
The method isAutoDelete does only exist in AMQPAL\Options\QueueOptions, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
524
        $options->isExclusive()->willReturn(true);
0 ignored issues
show
Bug introduced by
The method isExclusive does only exist in AMQPAL\Options\QueueOptions, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
525
        $options->isNoWait()->willReturn(true);
0 ignored issues
show
Bug introduced by
The method isNoWait does only exist in AMQPAL\Options\QueueOptions, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
526
        $options->getName()->willReturn('queueName');
0 ignored issues
show
Bug introduced by
The method getName does only exist in AMQPAL\Options\QueueOptions, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
527
        $options->getArguments()->willReturn(['arg1' => 'value1']);
0 ignored issues
show
Bug introduced by
The method getArguments does only exist in AMQPAL\Options\QueueOptions, but not in Prophecy\Prophecy\ObjectProphecy.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
528
        $options->isExclusive()->willReturn(true);
529
530
        return $options;
531
    }
532
}
533