Example #1
0
 public function testFlattenObjectWithSubObjects()
 {
     $b1a = $this->getUniqueString();
     $b1b = $this->getUniqueString();
     $b2a = $this->getUniqueString();
     $b2b = $this->getUniqueString();
     $b1 = new ObjectInflatorTestBTestClass();
     $b1->setA($b1a);
     $b1->setB($b1b);
     $b2 = new ObjectInflatorTestBTestClass();
     $b2->setA($b2a);
     $b2->setB($b2b);
     $array1 = array(10, 55, 'a', 'F');
     $array2 = array($b1, $b2);
     $array2AsArray = array(array('__php_class' => 'Aspyct\\MongoMap\\ObjectInflatorTestBTestClass', 'a' => $b1a, 'b' => $b1b), array('__php_class' => 'Aspyct\\MongoMap\\ObjectInflatorTestBTestClass', 'a' => $b2a, 'b' => $b2b));
     $publicWSet = $array1;
     $publicWoSet = $this->getUniqueString();
     $publicNonExisting = $this->getUniqueString();
     $protectedWSet = $array2;
     $protectedWoSet = $this->getUniqueString();
     $privateWSet = $this->getUniqueString();
     $privateWoSet = $this->getUniqueString();
     $expected = array('__php_class' => 'Aspyct\\MongoMap\\ObjectInflatorTestATestClass', 'publicWSet' => $array1, 'publicWoSet' => $publicWoSet, 'protectedWSet' => $array2AsArray, 'protectedWoSet' => $protectedWoSet, 'privateWSet' => $privateWSet, 'privateWoSet' => $privateWoSet);
     $obj = new ObjectInflatorTestATestClass();
     $obj->setPublicWSet($publicWSet);
     $obj->publicWoSet = $publicWoSet;
     $obj->setProtectedWSet($protectedWSet);
     $obj->defineProtectedWoSet($protectedWoSet);
     $obj->setPrivateWSet($privateWSet);
     $obj->definePrivateWoSet($privateWoSet);
     $obj->publicNonExisting = $publicNonExisting;
     $actual = $this->object->flatten($obj);
     $this->assertEquals($expected, $actual);
 }
Example #2
0
 public function testInflateFlatArray()
 {
     $publicWSet = $this->getUniqueString();
     $publicWoSet = $this->getUniqueString();
     $publicNonExisting = $this->getUniqueString();
     $protectedWSet = $this->getUniqueString();
     $protectedWoSet = $this->getUniqueString();
     $privateWSet = $this->getUniqueString();
     $privateWoSet = $this->getUniqueString();
     $expected = array('publicWSet' => $publicWSet, 'publicWoSet' => $publicWoSet, 'publicNonExisting' => $publicNonExisting, 'protectedWSet' => $protectedWSet, 'protectedWoSet' => $protectedWoSet, 'privateWSet' => $privateWSet, 'privateWoSet' => $privateWoSet);
     $actual = $this->object->inflate($expected);
     $this->assertEquals($expected, $actual);
 }