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

EventTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 3
c 3
b 1
f 2
lcom 1
cbo 3
dl 0
loc 58
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testAcknowledge() 0 18 1
A testReject() 0 20 1
1
<?php
2
3
namespace Equip\Queue;
4
5
use Exception;
6
use League\Event\EmitterInterface;
7
8
class EventTest extends TestCase
9
{
10
    /**
11
     * @var EmitterInterface
12
     */
13
    private $emitter;
14
15
    /**
16
     * @var Event
17
     */
18
    private $event;
19
20
    protected function setUp()
21
    {
22
        $this->emitter = $this->createMock(EmitterInterface::class);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock(\Leagu...mitterInterface::class) of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<League\Event\EmitterInterface> of property $emitter.

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...
23
        $this->event = new Event($this->emitter);
24
    }
25
26
    public function testAcknowledge()
27
    {
28
        $message = new Message(
29
            'queue',
30
            'handler',
31
            ['foo' => 'bar']
32
        );
33
34
        $this->emitter
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<League\Event\EmitterInterface>.

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...
35
            ->expects($this->exactly(2))
36
            ->method('emit')
37
            ->withConsecutive(
38
                [Event::QUEUE_ACKNOWLEDGE, $message],
39
                [sprintf('%s.%s', Event::QUEUE_ACKNOWLEDGE, $message->handler()), $message]
40
            );
41
42
        $this->event->acknowledge($message);
43
    }
44
45
    public function testReject()
46
    {
47
        $message = new Message(
48
            'queue',
49
            'handler',
50
            ['foo' => 'bar']
51
        );
52
53
        $exception = new Exception;
54
55
        $this->emitter
0 ignored issues
show
Bug introduced by
The method expects() does not seem to exist on object<League\Event\EmitterInterface>.

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...
56
            ->expects($this->exactly(2))
57
            ->method('emit')
58
            ->withConsecutive(
59
                [Event::QUEUE_REJECT, $message, $exception],
60
                [sprintf('%s.%s', Event::QUEUE_REJECT, $message->handler()), $message, $exception]
61
            );
62
63
        $this->event->reject($message, $exception);
64
    }
65
}
66