Completed
Pull Request — master (#30)
by
unknown
05:39
created

HetrixtoolsServiceResponseTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B testHetrixtoolsServiceResponse() 0 33 1
A testHetrixtoolsServiceResponseWrongJson() 0 10 1
1
<?php
2
namespace Azine\MailgunWebhooksBundle\Tests\Services\HetrixtoolsService;
3
4
5
use Azine\MailgunWebhooksBundle\Services\HetrixtoolsService\HetrixtoolsServiceResponse;
6
7
class HetrixtoolsServiceResponseTest extends \PHPUnit_Framework_TestCase
8
{
9
    public function testHetrixtoolsServiceResponse()
10
    {
11
        $responseJson = '{
12
            "status": "SUCCESS",
13
            "api_calls_left": 1976,
14
            "blacklist_check_credits_left": 81,
15
            "blacklisted_count": 3,
16
            "blacklisted_on": [
17
                {
18
                    "rbl": "dnsbl.test.com",
19
                    "delist": "https://exchange.test.com/ip/44.44.44.44"
20
                },
21
                {
22
                    "rbl": "pbl.test.org",
23
                    "delist": "https://www.test.org/query/ip/44.44.44.44"
24
                },
25
                {
26
                    "rbl": "zen.test.org",
27
                    "delist": "https://www.test.org/query/ip/44.44.44.44"
28
                }
29
            ],
30
            "links": {
31
                "report_link": "https://test.com/report/blacklist/token/",
32
                "whitelabel_report_link": "",
33
                "api_report_link": "https://api.test.com/v1/token/report/44.44.44.44/",
34
                "api_blacklist_check_link": "https://api.test.com/v2/token/blacklist-check/ipv4/44.44.44.44/"
35
            }
36
        }';
37
38
        $response = HetrixtoolsServiceResponse::fromJson($responseJson);
39
40
        $this->assertInstanceOf(HetrixtoolsServiceResponse::class, $response);
41
    }
42
43
    /**
44
     * @expectedException \InvalidArgumentException
45
     */
46
    public function testHetrixtoolsServiceResponseWrongJson()
47
    {
48
        //Test with empty string
49
        $responseJson = '';
50
        HetrixtoolsServiceResponse::fromJson($responseJson);
51
52
        //Test with invalid Json
53
        $responseJson = 'invalidJson';
54
        HetrixtoolsServiceResponse::fromJson($responseJson);
55
    }
56
}