Completed
Branch v1 (ffe92e)
by Julián
02:44
created

NotificationTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 5
c 4
b 1
f 0
lcom 1
cbo 3
dl 0
loc 57
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 10 1
A testDefaults() 0 6 1
A testMessage() 0 6 1
A testReceivers() 0 9 1
A testResults() 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
use Jgut\Tify\Result;
16
17
/**
18
 * Notification tests.
19
 */
20
class NotificationTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * @var \Jgut\Tify\Message
24
     */
25
    protected $message;
26
27
    /**
28
     * @var \Jgut\Tify\Notification
29
     */
30
    protected $notification;
31
32
    public function setUp()
33
    {
34
        $this->message = $this->getMock(Message::class, [], [], '', false);
35
        $receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false);
36
37
        $this->notification = $this->getMockForAbstractClass(
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockForAbstrac...age, array($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...
38
            Notification::class,
39
            [$this->message, [$receiver]]
40
        );
41
    }
42
43
    public function testDefaults()
44
    {
45
        self::assertEquals($this->message, $this->notification->getMessage());
46
        self::assertCount(1, $this->notification->getReceivers());
47
        self::assertCount(0, $this->notification->getResults());
48
    }
49
50
    public function testMessage()
51
    {
52
        $message = $this->getMock(Message::class, [], [], '', false);
53
        $this->notification->setMessage($message);
54
        self::assertEquals($message, $this->notification->getMessage());
55
    }
56
57
    public function testReceivers()
58
    {
59
        $receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false);
60
        $this->notification->addReceiver($receiver);
61
        self::assertCount(1, $this->notification->getReceivers());
62
63
        $this->notification->clearReceivers();
64
        self::assertCount(0, $this->notification->getReceivers());
65
    }
66
67
    public function testResults()
68
    {
69
        $result = new Result('aaa', new \DateTime('now', new \DateTimeZone('UTC')));
70
        $this->notification->addResult($result);
71
        self::assertCount(1, $this->notification->getResults());
72
73
        $this->notification->clearResults();
74
        self::assertCount(0, $this->notification->getResults());
75
    }
76
}
77