Completed
Pull Request — develop (#48)
by Luís
02:58 queued 50s
created

DecoderTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 7
dl 0
loc 18
rs 10
1
<?php
2
namespace PHPSC\PagSeguro\Purchases\Subscriptions;
3
4
use DateTime;
5
use PHPSC\PagSeguro\Purchases\Details;
6
use PHPSC\PagSeguro\Customer\Address;
7
use PHPSC\PagSeguro\Customer\Customer;
8
use PHPSC\PagSeguro\Customer\Phone;
9
10
/**
11
 * @author Renato Moura <[email protected]>
12
 */
13
class DecoderTest extends \PHPUnit_Framework_TestCase
14
{
15
    public function testDecodeShouldDoReturningObjectSubscription()
16
    {
17
        $detailsDate = new DateTime('2011-11-23T13:40:00.000-02:00');
18
        $detailsLastEventDate = new DateTime('2011-11-25T20:04:00.000-02:00');
19
        $detailsAddress = new Address('SP', 'SAO PAULO', '01421000', 'J Paulista', 'ALAMEDAITU', '78', 'ap.2601');
20
        $customer = new Customer('[email protected]', 'Nome Comprador', new Phone('11', '30389678'), $detailsAddress);
21
        $details = new Details('C08984', 'REF1234', 'CANCELLED', $detailsDate, $detailsLastEventDate, $customer);
22
23
        $subscription = new Subscription('Seguro Notebook', $details, '538C53', 'auto');
24
25
        $obj = simplexml_load_file(__DIR__.'/xml/preApproval.xml');
26
27
        $decoder = new Decoder;
28
        $this->assertEquals($subscription, $decoder->decode($obj));
29
    }
30
}
31