Passed
Push — develop ( 726e4d...2a8883 )
by Luís
37s
created

DecoderTest::testDecodeShouldDoReturningObjectTransaction()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 25
rs 8.8571
cc 1
eloc 18
nc 1
nop 0
1
<?php
2
namespace PHPSC\PagSeguro\Purchases\Transactions;
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
use PHPSC\PagSeguro\Items\Item;
10
use PHPSC\PagSeguro\Items\Items;
11
use PHPSC\PagSeguro\Shipping\Shipping;
12
13
/**
14
 * @author Renato Moura <[email protected]>
15
 */
16
class DecoderTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testDecodeShouldDoReturningObjectTransaction()
19
    {
20
        $detailsDate = new DateTime('2011-02-10T16:13:41.000-03:00');
21
        $detailsLastEventDate = new DateTime('2011-02-10T19:15:11.000-03:00');
22
        $detailsAddress = new Address('AC', 'Sao Maite', '99500079', 'Centro', 'R Delgado', '55', 'Fundos');
23
        $customer = new Customer('[email protected]', 'FooBar', new Phone('11', '99999999'), $detailsAddress);
24
        $details = new Details('9E884542', 'REF1234', '6', $detailsDate, $detailsLastEventDate, $customer);
25
26
        $paymentMethod = new PaymentMethod(1, 101);
27
        $escrowEndDate = new DateTime('2011-03-10T08:00:00.000-03:00');
28
        $payment = new Payment($paymentMethod, 49900.00, 0.01, 0.04, 49900.03, 0.02, 1, $escrowEndDate);
29
30
        $shippingAddress = new Address('CE', 'Ortega', '40610912', 'Ipe', 'R. Regina', '36', 'Bl.A');
31
        $shipping = new Shipping(2, $shippingAddress, 23.45);
32
33
        $items = new Items;
34
        $items->add(new Item(77, 'Produto 01', 2.5, 4, 20, 300));
35
        $items->add(new Item(88, 'Produto 02', 342.51, 3, 134.98, 1000));
36
37
        $transaction = new Transaction($details, $payment, 2, $items, $shipping);
38
39
        $obj = simplexml_load_file(__DIR__.'/xml/transactionFull.xml');
40
        $decoder = new Decoder;
41
        $this->assertEquals($transaction, $decoder->decode($obj));
42
    }
43
}
44