| 1 | <?php |
||
| 13 | class CompositionTest extends SerializerTestCase |
||
| 14 | { |
||
| 15 | public function testSerialize() |
||
| 16 | { |
||
| 17 | $data = $this->serialize(new Owner(true)); |
||
| 18 | |||
| 19 | $this->assertTrue(isset($data['car'])); |
||
| 20 | $this->assertTrue(isset($data['car']['color'])); |
||
| 21 | $this->assertTrue(isset($data['name'])); |
||
| 22 | $this->assertTrue(isset($data['birthday'])); |
||
| 23 | } |
||
| 24 | |||
| 25 | public function testDeserialize() |
||
| 26 | { |
||
| 27 | $data = json_decode('{"name":"Foobar","car":{"super_model":"val_model","car_size":"val_size","color":"val_color"},"birthday":"1995-07-14T20:07:41+02:00"}', true); |
||
| 28 | $obj = $this->deserialize($data, Owner::class); |
||
| 29 | |||
| 30 | $this->assertPropertyValue($obj, 'name', 'Foobar'); |
||
| 31 | $car = $obj->getCar(); |
||
| 32 | $this->assertInstanceOf(Car::class, $car); |
||
| 33 | $this->assertPropertyValue($car, 'color', 'val_color'); |
||
| 34 | } |
||
| 35 | } |
||
| 36 |