| 1 | <?php |
||
| 4 | class PhoneTest extends \PHPUnit_Framework_TestCase |
||
| 5 | { |
||
| 6 | /** |
||
| 7 | * @test |
||
| 8 | */ |
||
| 9 | public function constructMustTruncateData() |
||
| 10 | { |
||
| 11 | $phone = new Phone(479, 1234567890); |
||
| 12 | |||
| 13 | $this->assertAttributeEquals(479, 'areaCode', $phone); |
||
| 14 | $this->assertAttributeEquals(1234567890, 'number', $phone); |
||
| 15 | } |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @test |
||
| 19 | */ |
||
| 20 | public function gettersShouldReturnConfiguredData() |
||
| 21 | { |
||
| 22 | $phone = new Phone(47, 98761234); |
||
| 23 | |||
| 24 | $this->assertEquals(47, $phone->getAreaCode()); |
||
| 25 | $this->assertEquals(98761234, $phone->getNumber()); |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @test |
||
| 30 | */ |
||
| 31 | public function xmlSerializeMustAppendFormattedPhoneData() |
||
| 32 | { |
||
| 33 | |||
| 34 | $data = simplexml_load_string('<?xml version="1.0" encoding="UTF-8"?><data />'); |
||
| 35 | |||
| 36 | $phone = new Phone(47, 1234567890); |
||
| 37 | $xml = $phone->xmlSerialize($data); |
||
| 38 | |||
| 39 | $this->assertSame($data, $xml); |
||
| 40 | $this->assertEquals(47, (string) $xml->phone->areaCode); |
||
| 41 | $this->assertEquals(1234567890, (string) $xml->phone->number); |
||
| 42 | } |
||
| 43 | } |
||
| 44 |