Completed
Push — master ( f47fb6...c9af04 )
by Julián
02:24
created

NotificationTest::testInvalidParameter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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->getMockBuilder(Message::class)->disableOriginalConstructor()->getMock();
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
    /**
49
     * @expectedException \InvalidArgumentException
50
     */
51
    public function testInvalidParameter()
52
    {
53
        $this->notification->setParameter('made-up-parameter', true);
54
    }
55
56
    public function testMessage()
57
    {
58
        $message = $this->getMockBuilder(Message::class)->disableOriginalConstructor()->getMock();
59
        $this->notification->setMessage($message);
60
        self::assertEquals($message, $this->notification->getMessage());
61
    }
62
63
    public function testReceivers()
64
    {
65
        $receiver = $this->getMockForAbstractClass(AbstractReceiver::class, [], '', false);
66
        $this->notification->addReceiver($receiver);
67
        self::assertCount(2, $this->notification->getReceivers());
68
69
        $this->notification->clearReceivers();
70
        self::assertCount(0, $this->notification->getReceivers());
71
    }
72
}
73