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

NotificationPreferencesTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createNotification() 0 10 1
A testShouldCreateNotificationPreference() 0 5 1
A testShouldGetNotificationPreference() 0 11 1
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