Passed
Push — develop ( 19a8b8...726e4d )
by Luís
29s
created

CustomerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 1
cbo 4
dl 0
loc 62
rs 10
1
<?php
2
namespace PHPSC\PagSeguro\Customer;
3
4
class CustomerTest extends \PHPUnit_Framework_TestCase
5
{
6
    /**
7
     * @test
8
     */
9
    public function constructShouldConfigureTheAttributes()
10
    {
11
        $phone = new Phone(11, 999999999);
12
        $address = new Address('aa', 'aa', '2123', 'aa', 'asdad', 12312);
13
        $customer = new Customer('[email protected]', 'aa', $phone, $address);
14
15
        $this->assertAttributeEquals('[email protected]', 'email', $customer);
16
        $this->assertAttributeEquals('aa', 'name', $customer);
17
        $this->assertAttributeSame($phone, 'phone', $customer);
18
        $this->assertAttributeSame($address, 'address', $customer);
19
20
        return $customer;
21
    }
22
23
    /**
24
     * @test
25
     */
26
    public function gettersShouldRetrieveConfiguredData()
27
    {
28
        $phone = new Phone(11, 999999999);
29
        $address = new Address('aa', 'aa', '2123', 'aa', 'asdad', 12312);
30
        $customer = new Customer('[email protected]', 'aa', $phone, $address);
31
32
        $this->assertEquals('[email protected]', $customer->getEmail());
33
        $this->assertEquals('aa', $customer->getName());
34
        $this->assertSame($phone, $customer->getPhone());
35
        $this->assertSame($address, $customer->getAddress());
36
    }
37
38
    /**
39
     * @test
40
     */
41
    public function xmlSerializeMustAppendFormattedCustomerData()
42
    {
43
        $this->markTestSkipped();
44
45
        $name = str_repeat('a', 55);
46
        $xml = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><test />');
47
48
        $phone    = $this->createMock(Phone::class);
49
        $address  = $this->createMock(Address::class);
50
        $customer = new Customer($name . '@test.com', $name, $phone, $address);
51
52
        $phone->expects($this->any())
53
              ->method('xmlSerialize')
54
              ->with($this->isInstanceOf('SimpleXMLElement'));
55
56
        $address->expects($this->any())
57
                ->method('xmlSerialize')
58
                ->with($this->isInstanceOf('SimpleXMLElement'));
59
60
        $customer->xmlSerialize($xml);
61
62
        $this->assertEquals($name . '@test', (string) $xml->sender->email);
63
        $this->assertEquals(str_repeat('a', 50), (string) $xml->sender->name);
64
    }
65
}
66