Passed
Branch master (461ffe)
by João Felipe Magro
05:37 queued 02:32
created

XmlServiceTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 38
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testValidateSuccessfully() 0 21 1
A testValidateShouldReturnFalse() 0 5 1
1
<?php
2
3
namespace Tests\Classes\Services;
4
5
use Ipag\Classes\Services\XmlService;
6
use PHPUnit\Framework\TestCase;
7
8
class XmlServiceTest extends TestCase
9
{
10
    private $xmlService;
11
12
    public function setUp()
13
    {
14
        parent::setUp();
15
        $this->xmlService = new XmlService();
16
    }
17
18
    public function testValidateSuccessfully()
19
    {
20
        $xml = '<?xml version="1.0" encoding="utf-8" ?>
21
            <retorno>
22
                <id_transacao>0e66639220f14eb9b4ebb59d2cb16c01</id_transacao>
23
                <valor>15</valor>
24
                <num_pedido>1521513946617</num_pedido>
25
                <status_pagamento>8</status_pagamento>
26
                <mensagem_transacao>Transação Autorizada</mensagem_transacao>
27
                <metodo>visa</metodo>
28
                <operadora>zoop</operadora>
29
                <operadora_mensagem>Transação autorizada</operadora_mensagem>
30
                <id_librepag>996327</id_librepag>
31
                <autorizacao_id>123456</autorizacao_id>
32
                <redirect>false</redirect>
33
                <data_pagamento>0000-00-00 00:00:00</data_pagamento>
34
                <num_parcela>2</num_parcela>
35
            </retorno>';
36
37
        $this->assertInstanceOf(\SimpleXMLElement::class, $this->xmlService->validate($xml));
38
    }
39
40
    public function testValidateShouldReturnFalse()
41
    {
42
        $xml = 'error';
43
        $this->assertFalse($this->xmlService->validate($xml));
44
    }
45
}
46