Completed
Push — master ( 4cd93a...e8f4ec )
by Thomas Mauro
10:51
created

QueueTest::testSetOptionsWithArray()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 18
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)
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 testSetOptionsWithArray()
47
    {
48
        $options = ['name' => 'queueName'];
49
        $resource = $this->prophesize(\AMQPQueue::class);
50
51
        $resource->setFlags(Argument::any())
52
            ->shouldBeCalled();
53
        $resource->setName('queueName')->shouldBeCalled();
54
        $resource->setArguments([])->shouldBeCalled();
55
56
        $queue = new Queue();
57
        $queue->setResource($resource->reveal());
58
59
        static::assertSame($queue, $queue->setOptions($options));
60
        $queueOptions = $queue->getOptions();
61
        static::assertInstanceOf(Options\QueueOptions::class, $queueOptions);
62
        static::assertEquals('queueName', $queueOptions->getName());
63
    }
64
65
    public function testDeclareQueue()
66
    {
67
        $options = $this->getDefaultOptionsProphet();
68
        $resource = $this->prophesize(\AMQPQueue::class);
69
70
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
71
            ->shouldBeCalled();
72
        $resource->setName('queueName')->shouldBeCalled();
73
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
74
75
        $resource->declareQueue()->shouldBeCalled();
76
77
        $exchange = new Queue();
78
        $exchange->setResource($resource->reveal());
79
        $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...
80
81
        static::assertSame($exchange, $exchange->declareQueue());
82
    }
83
84
    /**
85
     * @dataProvider deleteProvider()
86
     */
87
    public function testDelete($ifUnused, $ifEmpty, $noWait, $flags)
88
    {
89
        $options = $this->getDefaultOptionsProphet();
90
        $resource = $this->prophesize(\AMQPQueue::class);
91
92
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
93
            ->shouldBeCalled();
94
        $resource->setName('queueName')->shouldBeCalled();
95
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
96
97
        $resource->delete($flags)->shouldBeCalled();
98
99
        $exchange = new Queue();
100
        $exchange->setResource($resource->reveal());
101
        $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...
102
103
        static::assertSame($exchange, $exchange->delete($ifUnused, $ifEmpty, $noWait));
104
    }
105
106
    public function testBind()
107
    {
108
        $arguments = ['arg2' => 'value2'];
109
110
        $options = $this->getDefaultOptionsProphet();
111
        $resource = $this->prophesize(\AMQPQueue::class);
112
113
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
114
            ->shouldBeCalled();
115
        $resource->setName('queueName')->shouldBeCalled();
116
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
117
118
        $resource->bind('exchangeName', 'routingKey', $arguments)->shouldBeCalled();
119
120
        $queue = new Queue();
121
        $queue->setResource($resource->reveal());
122
        $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...
123
124
        static::assertSame($queue, $queue->bind('exchangeName', 'routingKey', false, $arguments));
125
    }
126
127
    public function testUnbind()
128
    {
129
        $arguments = ['arg2' => 'value2'];
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)
135
            ->shouldBeCalled();
136
        $resource->setName('queueName')->shouldBeCalled();
137
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
138
139
        $resource->unbind('exchangeName', 'routingKey', $arguments)->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->unbind('exchangeName', 'routingKey', $arguments));
146
    }
147
148
    public function testAck()
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)
154
            ->shouldBeCalled();
155
        $resource->setName('queueName')->shouldBeCalled();
156
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
157
158
        $resource->ack('deliveryTag', AMQP_NOPARAM)->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'));
165
    }
166
167
    public function testAckMultiple()
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)
173
            ->shouldBeCalled();
174
        $resource->setName('queueName')->shouldBeCalled();
175
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
176
177
        $resource->ack('deliveryTag', AMQP_MULTIPLE)->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->ack('deliveryTag', true));
184
    }
185
186
    public function testNack()
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)
192
            ->shouldBeCalled();
193
        $resource->setName('queueName')->shouldBeCalled();
194
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
195
196
        $resource->nack('deliveryTag', AMQP_NOPARAM)->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'));
203
    }
204
205
    public function testNackRequeue()
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)
211
            ->shouldBeCalled();
212
        $resource->setName('queueName')->shouldBeCalled();
213
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
214
215
        $resource->nack('deliveryTag', AMQP_REQUEUE)->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', true));
222
    }
223
224
    public function testNackMultiple()
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)
230
            ->shouldBeCalled();
231
        $resource->setName('queueName')->shouldBeCalled();
232
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
233
234
        $resource->nack('deliveryTag', 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', false, true));
241
    }
242
243
    public function testNackRequeueMultiple()
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)
249
            ->shouldBeCalled();
250
        $resource->setName('queueName')->shouldBeCalled();
251
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
252
253
        $resource->nack('deliveryTag', AMQP_REQUEUE | AMQP_MULTIPLE)->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->nack('deliveryTag', true, true));
260
    }
261
262
    public function testReject()
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)
268
            ->shouldBeCalled();
269
        $resource->setName('queueName')->shouldBeCalled();
270
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
271
272
        $resource->reject('deliveryTag', AMQP_NOPARAM)->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'));
279
    }
280
281
    public function testRejectRequeue()
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)
287
            ->shouldBeCalled();
288
        $resource->setName('queueName')->shouldBeCalled();
289
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
290
291
        $resource->reject('deliveryTag', AMQP_REQUEUE)->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->reject('deliveryTag', true));
298
    }
299
300
    public function testPurge()
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)
306
            ->shouldBeCalled();
307
        $resource->setName('queueName')->shouldBeCalled();
308
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
309
310
        $resource->purge()->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->purge());
317
    }
318
319
    public function testCancel()
320
    {
321
        $options = $this->getDefaultOptionsProphet();
322
        $resource = $this->prophesize(\AMQPQueue::class);
323
324
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
325
            ->shouldBeCalled();
326
        $resource->setName('queueName')->shouldBeCalled();
327
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
328
329
        $resource->cancel('')->shouldBeCalled();
330
331
        $queue = new Queue();
332
        $queue->setResource($resource->reveal());
333
        $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...
334
335
        static::assertSame($queue, $queue->cancel(null));
336
    }
337
338
    public function testGet()
339
    {
340
        $options = $this->getDefaultOptionsProphet();
341
        $resource = $this->prophesize(\AMQPQueue::class);
342
        $messageMapper = $this->prophesize(MessageMapper::class);
343
344
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
345
            ->shouldBeCalled();
346
        $resource->setName('queueName')->shouldBeCalled();
347
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
348
349
        $resource->get(AMQP_NOPARAM)->shouldBeCalled();
350
351
        $queue = new Queue();
352
        $queue->setResource($resource->reveal());
353
        $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...
354
        $queue->setMessageMapper($messageMapper->reveal());
355
356
        static::assertNull($queue->get());
357
    }
358
359
    public function testGetWithAutoAck()
360
    {
361
        $options = $this->getDefaultOptionsProphet();
362
        $resource = $this->prophesize(\AMQPQueue::class);
363
        $messageMapper = $this->prophesize(MessageMapper::class);
364
365
        $messageMapper->toMessage(Argument::any())->shouldNotBeCalled();
366
367
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
368
            ->shouldBeCalled();
369
        $resource->setName('queueName')->shouldBeCalled();
370
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
371
372
        $resource->get(AMQP_AUTOACK)->shouldBeCalled();
373
374
        $queue = new Queue();
375
        $queue->setResource($resource->reveal());
376
        $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...
377
        $queue->setMessageMapper($messageMapper->reveal());
378
379
        static::assertNull($queue->get(true));
380
    }
381
382
    public function testGetWithAutoAckAndMessage()
383
    {
384
        $options = $this->getDefaultOptionsProphet();
385
        $resource = $this->prophesize(\AMQPQueue::class);
386
        $message = $this->prophesize(Message::class);
387
        $libMessage = $this->prophesize(\AMQPEnvelope::class);
388
        $messageMapper = $this->prophesize(MessageMapper::class);
389
390
        $messageMapper->toMessage($libMessage->reveal())->shouldBeCalled()->willReturn($message->reveal());
391
392
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
393
            ->shouldBeCalled();
394
        $resource->setName('queueName')->shouldBeCalled();
395
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
396
397
        $resource->get(AMQP_AUTOACK)
398
            ->shouldBeCalled()
399
            ->willReturn($libMessage->reveal());
400
401
        $queue = new Queue();
402
        $queue->setResource($resource->reveal());
403
        $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...
404
        $queue->setMessageMapper($messageMapper->reveal());
405
406
        static::assertSame($message->reveal(), $queue->get(true));
407
    }
408
409
    public function testConsume()
410
    {
411
        $options = $this->getDefaultOptionsProphet();
412
        $resource = $this->prophesize(\AMQPQueue::class);
413
        $libMessage = $this->prophesize(\AMQPEnvelope::class);
414
        $messageMapper = $this->prophesize(MessageMapper::class);
415
416
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
417
            ->shouldBeCalled();
418
        $resource->setName('queueName')->shouldBeCalled();
419
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
420
421
        $resource->consume(Argument::type(ConsumerCallback::class), AMQP_NOPARAM, 'consumerTag')
422
            ->shouldBeCalled()
423
            ->willReturn($libMessage->reveal());
424
425
        $queue = new Queue();
426
        $queue->setResource($resource->reveal());
427
        $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...
428
        $queue->setMessageMapper($messageMapper->reveal());
429
430
        $callback = function () {
431
            
432
        };
433
434
        $ret = $queue->consume($callback, false, false, false, 'consumerTag');
435
436
        static::assertSame($queue, $ret);
437
    }
438
439
    /**
440
     * @dataProvider consumeProviderWithFlags
441
     */
442
    public function testConsumeWithFlags(array $consumeArgs, $flags, $consumerTag)
443
    {
444
        $options = $this->getDefaultOptionsProphet();
445
        $resource = $this->prophesize(\AMQPQueue::class);
446
        $libMessage = $this->prophesize(\AMQPEnvelope::class);
447
        $messageMapper = $this->prophesize(MessageMapper::class);
448
449
        $resource->setFlags(AMQP_NOPARAM | AMQP_DURABLE | AMQP_PASSIVE | AMQP_AUTODELETE | AMQP_EXCLUSIVE)
450
            ->shouldBeCalled();
451
        $resource->setName('queueName')->shouldBeCalled();
452
        $resource->setArguments(['arg1' => 'value1'])->shouldBeCalled();
453
454
        $resource->consume(null, $flags, $consumerTag)
455
            ->shouldBeCalled()
456
            ->willReturn($libMessage->reveal());
457
458
        $queue = new Queue();
459
        $queue->setResource($resource->reveal());
460
        $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...
461
        $queue->setMessageMapper($messageMapper->reveal());
462
463
        $ret = call_user_func_array([$queue, 'consume'], $consumeArgs);
464
        static::assertSame($queue, $ret);
465
    }
466
467
    public function consumeProviderWithFlags()
468
    {
469
        return [
470
            [
471
                [null, false, false, false, null],
472
                AMQP_NOPARAM, null
473
            ],
474
            [
475
                [null, true, false, false, null],
476
                AMQP_NOLOCAL, null
477
            ],
478
            [
479
                [null, false, true, false, null],
480
                AMQP_AUTOACK, null
481
            ],
482
            [
483
                [null, false, false, true, null],
484
                AMQP_EXCLUSIVE, null
485
            ],
486
            [
487
                [null, true, true, true, null],
488
                AMQP_NOLOCAL | AMQP_AUTOACK | AMQP_EXCLUSIVE, null
489
            ]
490
        ];
491
    }
492
493
    public function testSetAndGetChannel()
494
    {
495
        $channel = $this->prophesize(Channel::class);
496
497
        $exchange = new Queue();
498
        static::assertSame($exchange, $exchange->setChannel($channel->reveal()));
499
        static::assertSame($channel->reveal(), $exchange->getChannel());
500
    }
501
502
    public function testGetConnection()
503
    {
504
        $channel = $this->prophesize(Channel::class);
505
        $connection = $this->prophesize(Connection::class);
506
507
        $channel->getConnection()->willReturn($connection);
508
509
        $exchange = new Queue();
510
        static::assertSame($exchange, $exchange->setChannel($channel->reveal()));
511
        static::assertSame($connection->reveal(), $exchange->getConnection());
512
    }
513
514
    public function deleteProvider()
515
    {
516
        return [
517
            [true, true, true, AMQP_NOPARAM | AMQP_IFUNUSED | AMQP_IFEMPTY | AMQP_NOWAIT],
518
            [true, true, false, AMQP_NOPARAM | AMQP_IFUNUSED | AMQP_IFEMPTY],
519
            [true, false, true, AMQP_NOPARAM | AMQP_IFUNUSED | AMQP_NOWAIT],
520
            [true, false, false, AMQP_NOPARAM | AMQP_IFUNUSED],
521
            [false, true, true, AMQP_NOPARAM | AMQP_IFEMPTY | AMQP_NOWAIT],
522
            [false, true, false, AMQP_NOPARAM | AMQP_IFEMPTY],
523
            [false, false, true, AMQP_NOPARAM | AMQP_NOWAIT],
524
            [false, false, false, AMQP_NOPARAM],
525
        ];
526
    }
527
528
    /**
529
     * @return Options\QueueOptions|\Prophecy\Prophecy\ObjectProphecy
530
     */
531
    protected function getDefaultOptionsProphet()
532
    {
533
        /** @var Options\QueueOptions|\Prophecy\Prophecy\ObjectProphecy $options */
534
        $options = $this->prophesize(Options\QueueOptions::class);
535
536
        $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...
537
        $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...
538
        $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...
539
        $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...
540
        $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...
541
        $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...
542
        $options->isExclusive()->willReturn(true);
543
544
        return $options;
545
    }
546
}
547