| @@ 186-215 (lines=30) @@ | ||
| 183 | ; |
|
| 184 | } |
|
| 185 | ||
| 186 | public function testSerializeThreeLevel() |
|
| 187 | { |
|
| 188 | $this->createNewInstance(); |
|
| 189 | ||
| 190 | $this |
|
| 191 | ->given($cart = $this->createNewCart()) |
|
| 192 | ->and($cartItem = $this->createNewCartItem()) |
|
| 193 | ->and($cart->addCartItemList($cartItem)) |
|
| 194 | ->then |
|
| 195 | ->array($data = $this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\Cart')) |
|
| 196 | ->isIdenticalTo([ |
|
| 197 | 'status' => 'payed', |
|
| 198 | 'clientPhoneNumber' => '+33 1 23 45 67 89', |
|
| 199 | 'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339), |
|
| 200 | 'cart_items' => [ |
|
| 201 | [ |
|
| 202 | 'amount' => 2, |
|
| 203 | 'createdAt' => (new \DateTime('2015-09-20T12:11:00'))->format(DateTime::RFC3339), |
|
| 204 | 'data' => [ |
|
| 205 | 'when' => (new \DateTime('2015-09-20T15:00:00'))->format(DateTime::RFC3339), |
|
| 206 | 'who' => 'John', |
|
| 207 | ], |
|
| 208 | 'product' => '/v1/products/10', |
|
| 209 | 'cartItemDetailList' => [], |
|
| 210 | ], |
|
| 211 | ], |
|
| 212 | 'order' => null, |
|
| 213 | ]) |
|
| 214 | ; |
|
| 215 | } |
|
| 216 | ||
| 217 | /** |
|
| 218 | * testJsonEncodeRelationWithoutLinkMultipleLevel |
|
| @@ 354-383 (lines=30) @@ | ||
| 351 | * @access public |
|
| 352 | * @return void |
|
| 353 | */ |
|
| 354 | public function testMultipleLevelSerialization() |
|
| 355 | { |
|
| 356 | $this->createNewInstance(); |
|
| 357 | $this |
|
| 358 | ->given($cart = $this->createNewCart()) |
|
| 359 | ->and($cartItem = $this->createNewCartItem()) |
|
| 360 | ->and($cartItem->setCart($cart)) |
|
| 361 | ->then |
|
| 362 | ->array($this->testedInstance->serialize($cart, 'Mapado\RestClientSdk\Tests\Model\Cart')) |
|
| 363 | ->isIdenticalTo([ |
|
| 364 | 'status' => 'payed', |
|
| 365 | 'clientPhoneNumber' => '+33 1 23 45 67 89', |
|
| 366 | 'createdAt' => (new \DateTime('2015-09-20T12:08:00'))->format(DateTime::RFC3339), |
|
| 367 | 'cart_items' => [ |
|
| 368 | [ |
|
| 369 | 'amount' => 2, |
|
| 370 | 'createdAt' => (new \DateTime('2015-09-20T12:11:00'))->format(DateTime::RFC3339), |
|
| 371 | 'data' => [ |
|
| 372 | 'when' => (new \DateTime('2015-09-20T15:00:00'))->format(DateTime::RFC3339), |
|
| 373 | 'who' => 'John', |
|
| 374 | ], |
|
| 375 | 'product' => '/v1/products/10', |
|
| 376 | 'cartItemDetailList' => [], |
|
| 377 | ], |
|
| 378 | ], |
|
| 379 | 'order' => null, |
|
| 380 | ]) |
|
| 381 | ||
| 382 | ; |
|
| 383 | } |
|
| 384 | ||
| 385 | /** |
|
| 386 | * testLinkedUnserialize |
|