| @@ 300-317 (lines=18) @@ | ||
| 297 | ); |
|
| 298 | } |
|
| 299 | ||
| 300 | public function testNestedMapping() |
|
| 301 | { |
|
| 302 | $transformer = $this->getTransformer(); |
|
| 303 | $document = $transformer->transform(new POPO(), array( |
|
| 304 | 'sub' => array( |
|
| 305 | 'type' => 'nested', |
|
| 306 | 'properties' => array('foo' => array()), |
|
| 307 | ), |
|
| 308 | )); |
|
| 309 | $data = $document->getData(); |
|
| 310 | ||
| 311 | $this->assertTrue(array_key_exists('sub', $data)); |
|
| 312 | $this->assertInternalType('array', $data['sub']); |
|
| 313 | $this->assertEquals(array( |
|
| 314 | array('foo' => 'foo'), |
|
| 315 | array('foo' => 'bar'), |
|
| 316 | ), $data['sub']); |
|
| 317 | } |
|
| 318 | ||
| 319 | public function tesObjectMapping() |
|
| 320 | { |
|
| @@ 319-336 (lines=18) @@ | ||
| 316 | ), $data['sub']); |
|
| 317 | } |
|
| 318 | ||
| 319 | public function tesObjectMapping() |
|
| 320 | { |
|
| 321 | $transformer = $this->getTransformer(); |
|
| 322 | $document = $transformer->transform(new POPO(), array( |
|
| 323 | 'sub' => array( |
|
| 324 | 'type' => 'object', |
|
| 325 | 'properties' => array('bar'), |
|
| 326 | ), |
|
| 327 | )); |
|
| 328 | $data = $document->getData(); |
|
| 329 | ||
| 330 | $this->assertTrue(array_key_exists('sub', $data)); |
|
| 331 | $this->assertInternalType('array', $data['sub']); |
|
| 332 | $this->assertEquals(array( |
|
| 333 | array('bar' => 'foo'), |
|
| 334 | array('bar' => 'bar'), |
|
| 335 | ), $data['sub']); |
|
| 336 | } |
|
| 337 | ||
| 338 | public function testObjectDoesNotRequireProperties() |
|
| 339 | { |
|
| @@ 487-507 (lines=21) @@ | ||
| 484 | $this->assertEquals('bar', $data['unmappedValue']); |
|
| 485 | } |
|
| 486 | ||
| 487 | public function testThatMappedObjectsDontNeedAnIdentifierField() |
|
| 488 | { |
|
| 489 | $transformer = $this->getTransformer(); |
|
| 490 | $document = $transformer->transform(new POPO(), array( |
|
| 491 | 'objWithoutIdentifier' => array( |
|
| 492 | 'type' => 'object', |
|
| 493 | 'properties' => array( |
|
| 494 | 'foo' => array(), |
|
| 495 | 'bar' => array() |
|
| 496 | ) |
|
| 497 | ), |
|
| 498 | )); |
|
| 499 | $data = $document->getData(); |
|
| 500 | ||
| 501 | $this->assertTrue(array_key_exists('objWithoutIdentifier', $data)); |
|
| 502 | $this->assertInternalType('array', $data['objWithoutIdentifier']); |
|
| 503 | $this->assertEquals(array( |
|
| 504 | 'foo' => 'foo', |
|
| 505 | 'bar' => 'foo' |
|
| 506 | ), $data['objWithoutIdentifier']); |
|
| 507 | } |
|
| 508 | ||
| 509 | public function testThatNestedObjectsDontNeedAnIdentifierField() |
|
| 510 | { |
|