Completed
Pull Request — master (#1)
by Adam
05:22 queued 03:01
created

QueueTest::testAdd()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 23
rs 9.0856
cc 1
eloc 17
nc 1
nop 0
1
<?php
2
3
namespace Equip\Queue;
4
5
use Equip\Queue\Driver\DriverInterface;
6
use Equip\Queue\Serializer\MessageSerializerInterface;
7
8
class QueueTest extends TestCase
9
{
10
    /**
11
     * @var DriverInterface
12
     */
13
    private $driver;
14
15
    /**
16
     * @var MessageSerializerInterface
17
     */
18
    private $serializer;
19
20
    /**
21
     * @var Queue
22
     */
23
    private $queue;
24
25
    protected function setUp()
26
    {
27
        $this->driver = $this->createMock(DriverInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\Equip...DriverInterface::class) of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<Equip\Queue\Driver\DriverInterface> of property $driver.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
        $this->serializer = $this->createMock(MessageSerializerInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\Equip...alizerInterface::class) of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<Equip\Queue\Seria...ageSerializerInterface> of property $serializer.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
29
        $this->queue = new Queue($this->driver, $this->serializer);
30
    }
31
32
    public function testAdd()
33
    {
34
        $queue = 'queue';
35
        $handler = 'handler';
36
        $data = ['foo' => 'bar'];
37
38
        $serialized_message = json_encode(compact('queue', 'handler', 'data'));
39
        $message = new Message($queue, $handler, $data);
40
41
        $this->driver
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<Equip\Queue\Driver\DriverInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
            ->expects($this->once())
43
            ->method('push')
44
            ->with('queue', $serialized_message)
45
            ->willReturn(true);
46
47
        $this->serializer
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<Equip\Queue\Seria...ageSerializerInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
48
            ->expects($this->once())
49
            ->method('serialize')
50
            ->with($message)
51
            ->willReturn($serialized_message);
52
53
        $this->assertTrue($this->queue->add($message));
54
    }
55
}
56