1 | <?php |
||
4 | class ItemTest extends \PHPUnit_Framework_TestCase |
||
5 | { |
||
6 | /** |
||
7 | * @var Item |
||
8 | */ |
||
9 | protected $item; |
||
10 | |||
11 | protected function setUp() |
||
12 | { |
||
13 | $this->item = new Item( |
||
14 | str_repeat('01', 51), |
||
15 | str_repeat('a very long description', 100), |
||
16 | 150.23, |
||
17 | 3, |
||
18 | 10.30, |
||
19 | 123 |
||
20 | ); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * @test |
||
25 | */ |
||
26 | public function constructorShouldConfigureTheAttributes() |
||
27 | { |
||
28 | $this->assertAttributeEquals(str_repeat('01', 51), 'id', $this->item); |
||
29 | $this->assertAttributeEquals(str_repeat('a very long description', 100), 'description', $this->item); |
||
30 | $this->assertAttributeEquals(150.23, 'amount', $this->item); |
||
31 | $this->assertAttributeEquals(3, 'quantity', $this->item); |
||
32 | $this->assertAttributeEquals(10.30, 'shippingCost', $this->item); |
||
33 | $this->assertAttributeEquals('123', 'weight', $this->item); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @test |
||
38 | */ |
||
39 | public function gettersShouldReturnTheAttributeValue() |
||
40 | { |
||
41 | $this->assertAttributeEquals($this->item->getId(), 'id', $this->item); |
||
42 | $this->assertAttributeEquals($this->item->getDescription(), 'description', $this->item); |
||
43 | $this->assertAttributeEquals($this->item->getAmount(), 'amount', $this->item); |
||
44 | $this->assertAttributeEquals($this->item->getQuantity(), 'quantity', $this->item); |
||
45 | $this->assertAttributeEquals($this->item->getShippingCost(), 'shippingCost', $this->item); |
||
46 | $this->assertAttributeEquals($this->item->getWeight(), 'weight', $this->item); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * @testAppendFormattedValuesOnAChildNode |
||
51 | */ |
||
52 | public function xmlSerializeShouldAppendFormattedValuesOnAChildNode() |
||
53 | { |
||
54 | $this->markTestSkipped(); |
||
55 | |||
56 | $data = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><data />'); |
||
57 | $xml = $this->item->xmlSerialize($data); |
||
58 | |||
59 | $this->assertEquals(str_repeat('01', 50), (string) $xml->id); |
||
60 | $this->assertEquals(substr(str_repeat('a very long description', 100), 0, 100), (string) $xml->description); |
||
61 | $this->assertEquals('150.23', (string) $xml->amount); |
||
62 | $this->assertEquals('3', (string) $xml->quantity); |
||
63 | $this->assertEquals('10.30', (string) $xml->shippingCost); |
||
64 | $this->assertEquals('123', (string) $xml->weight); |
||
65 | } |
||
66 | } |
||
67 |