@@ 311-328 (lines=18) @@ | ||
308 | ); |
|
309 | } |
|
310 | ||
311 | public function testNestedMapping() |
|
312 | { |
|
313 | $transformer = $this->getTransformer(); |
|
314 | $document = $transformer->transform(new POPO(), [ |
|
315 | 'sub' => [ |
|
316 | 'type' => 'nested', |
|
317 | 'properties' => ['foo' => []], |
|
318 | ], |
|
319 | ]); |
|
320 | $data = $document->getData(); |
|
321 | ||
322 | $this->assertTrue(array_key_exists('sub', $data)); |
|
323 | $this->assertInternalType('array', $data['sub']); |
|
324 | $this->assertSame([ |
|
325 | ['foo' => 'foo'], |
|
326 | ['foo' => 'bar'], |
|
327 | ], $data['sub']); |
|
328 | } |
|
329 | ||
330 | public function tesObjectMapping() |
|
331 | { |
|
@@ 330-347 (lines=18) @@ | ||
327 | ], $data['sub']); |
|
328 | } |
|
329 | ||
330 | public function tesObjectMapping() |
|
331 | { |
|
332 | $transformer = $this->getTransformer(); |
|
333 | $document = $transformer->transform(new POPO(), [ |
|
334 | 'sub' => [ |
|
335 | 'type' => 'object', |
|
336 | 'properties' => ['bar'], |
|
337 | ], |
|
338 | ]); |
|
339 | $data = $document->getData(); |
|
340 | ||
341 | $this->assertTrue(array_key_exists('sub', $data)); |
|
342 | $this->assertInternalType('array', $data['sub']); |
|
343 | $this->assertSame([ |
|
344 | ['bar' => 'foo'], |
|
345 | ['bar' => 'bar'], |
|
346 | ], $data['sub']); |
|
347 | } |
|
348 | ||
349 | public function testObjectDoesNotRequireProperties() |
|
350 | { |
|
@@ 453-473 (lines=21) @@ | ||
450 | $this->assertSame('parent', $document->getParent()); |
|
451 | } |
|
452 | ||
453 | public function testThatMappedObjectsDontNeedAnIdentifierField() |
|
454 | { |
|
455 | $transformer = $this->getTransformer(); |
|
456 | $document = $transformer->transform(new POPO(), [ |
|
457 | 'objWithoutIdentifier' => [ |
|
458 | 'type' => 'object', |
|
459 | 'properties' => [ |
|
460 | 'foo' => [], |
|
461 | 'bar' => [], |
|
462 | ], |
|
463 | ], |
|
464 | ]); |
|
465 | $data = $document->getData(); |
|
466 | ||
467 | $this->assertTrue(array_key_exists('objWithoutIdentifier', $data)); |
|
468 | $this->assertInternalType('array', $data['objWithoutIdentifier']); |
|
469 | $this->assertSame([ |
|
470 | 'foo' => 'foo', |
|
471 | 'bar' => 'foo', |
|
472 | ], $data['objWithoutIdentifier']); |
|
473 | } |
|
474 | ||
475 | public function testThatNestedObjectsDontNeedAnIdentifierField() |
|
476 | { |