1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Tests\Classes\Services; |
4
|
|
|
|
5
|
|
|
use Ipag\Classes\Services\CallbackService; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
use stdClass; |
8
|
|
|
|
9
|
|
|
class CallbackServiceTest extends TestCase |
10
|
|
|
{ |
11
|
|
|
public function testGetResponse() |
12
|
|
|
{ |
13
|
|
|
$expected = new stdClass(); |
14
|
|
|
$expected->tid = '123456789'; |
15
|
|
|
$expected->amount = 10.00; |
16
|
|
|
|
17
|
|
|
$expected->payment = new stdClass(); |
18
|
|
|
$expected->payment->status = '8'; |
19
|
|
|
|
20
|
|
|
$service = new CallbackService(); |
21
|
|
|
|
22
|
|
|
$xml = '<?xml version="1.0" encoding="utf-8" ?> |
23
|
|
|
<retorno> |
24
|
|
|
<id_transacao>123456789</id_transacao> |
25
|
|
|
<valor>10.00</valor> |
26
|
|
|
<num_pedido>123456</num_pedido> |
27
|
|
|
<status_pagamento>8</status_pagamento> |
28
|
|
|
<mensagem_transacao>Transação Autorizada</mensagem_transacao> |
29
|
|
|
<metodo>visa</metodo> |
30
|
|
|
<operadora>cielo</operadora> |
31
|
|
|
<operadora_mensagem>Transação autorizada</operadora_mensagem> |
32
|
|
|
<id_librepag>12345</id_librepag> |
33
|
|
|
<autorizacao_id>123456</autorizacao_id> |
34
|
|
|
<redirect>false</redirect> |
35
|
|
|
<url_autenticacao>https://minhaloja.com.br/ipag/retorno</url_autenticacao> |
36
|
|
|
</retorno>'; |
37
|
|
|
|
38
|
|
|
$response = $service->getResponse($xml); |
39
|
|
|
|
40
|
|
|
$this->assertInstanceOf('stdClass', $response); |
41
|
|
|
$this->assertEquals($expected->tid, $response->tid); |
42
|
|
|
$this->assertEquals($expected->amount, $response->amount); |
43
|
|
|
$this->assertEquals($expected->payment->status, $response->payment->status); |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
|