Completed
Push — master ( 020c5c...9dbce5 )
by Julián
08:49
created

NotificationTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 7
Bugs 1 Features 0
Metric Value
wmc 4
c 7
b 1
f 0
lcom 1
cbo 2
dl 0
loc 46
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A testDefaults() 0 5 1
A testMessage() 0 6 1
A testReceivers() 0 9 1
1
<?php
2
/**
3
 * Push notification services abstraction (http://github.com/juliangut/tify)
4
 *
5
 * @link https://github.com/juliangut/tify for the canonical source repository
6
 *
7
 * @license https://github.com/juliangut/tify/blob/master/LICENSE
8
 */
9
10
namespace Jgut\Tify\Tests\Notification;
11
12
use Jgut\Tify\Message;
13
use Jgut\Tify\Notification;
14
use Jgut\Tify\Receiver\AbstractReceiver;
15
16
/**
17
 * Notification tests.
18
 */
19
class NotificationTest extends \PHPUnit_Framework_TestCase
20
{
21
    /**
22
     * @var \Jgut\Tify\Message
23
     */
24
    protected $message;
25
26
    /**
27
     * @var \Jgut\Tify\Notification
28
     */
29
    protected $notification;
30
31
    public function setUp()
32
    {
33
        $this->message = $this->getMock(Message::class, [], [], '', false);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
34
        $receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false);
35
36
        $this->notification = $this->getMockForAbstractClass(
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...s->message, $receiver)) of type object<PHPUnit_Framework_MockObject_MockObject> is incompatible with the declared type object<Jgut\Tify\Notification> of property $notification.

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...
37
            Notification::class,
38
            [$this->message, $receiver]
39
        );
40
    }
41
42
    public function testDefaults()
43
    {
44
        self::assertEquals($this->message, $this->notification->getMessage());
45
        self::assertCount(1, $this->notification->getReceivers());
46
    }
47
48
    public function testMessage()
49
    {
50
        $message = $this->getMock(Message::class, [], [], '', false);
0 ignored issues
show
Deprecated Code introduced by
The method PHPUnit_Framework_TestCase::getMock() has been deprecated with message: Method deprecated since Release 5.4.0

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
51
        $this->notification->setMessage($message);
52
        self::assertEquals($message, $this->notification->getMessage());
53
    }
54
55
    public function testReceivers()
56
    {
57
        $receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false);
58
        $this->notification->addReceiver($receiver);
59
        self::assertCount(2, $this->notification->getReceivers());
60
61
        $this->notification->clearReceivers();
62
        self::assertCount(0, $this->notification->getReceivers());
63
    }
64
}
65