Completed
Pull Request — master (#201)
by
unknown
06:16
created

testShouldGetNotificationPreference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Moip\Tests\Resource;
4
5
use Moip\Tests\TestCase;
6
7
class NotificationPreferencesTest extends TestCase
8
{
9
    private function createNotification()
10
    {
11
        $this->mockHttpSession($this->body_notification_preference);
12
        $notification = $this->moip->notifications()->addEvent('ORDER.*')
13
            ->addEvent('PAYMENT.AUTHORIZED')
14
            ->setTarget('http://requestb.in/1dhjesw1')
15
            ->create();
16
17
        return $notification;
18
    }
19
20
    public function testShouldCreateNotificationPreference()
21
    {
22
        $notification = $this->createNotification();
23
        $this->assertNotEmpty($notification->getId());
24
    }
25
26
    public function testShouldGetNotificationPreference()
27
    {
28
        $this->mockHttpSession($this->body_notification_preference);
29
30
        $notification = $this->moip->notifications()->get('NPR-N6QZE3223P98');
31
        $this->assertEquals('NPR-N6QZE3223P98', $notification->getId());
32
        $this->assertEquals('WEBHOOK', $notification->getMedia());
33
        $this->assertEquals('994e3ffae9214fbc806d01de2dd5d341', $notification->getToken());
34
        $this->assertEquals('http://requestb.in/1dhjesw1', $notification->getTarget());
35
        $this->assertEquals(['ORDER.*', 'PAYMENT.AUTHORIZED', 'PAYMENT.CANCELLED'], $notification->getEvents());
36
    }
37
}
38