/** * Test serialization on an array of objects */ function testSerialization() { $this->_setUp('adodb', 'sqlite'); // make sure we have setup manager $this->assertTrue($this->m); include_once EP_TESTS . '/classes/inverses/src/eptInvOneManyA.php'; include_once EP_TESTS . '/classes/inverses/src/eptInvOneManyB.php'; // create eptInvOneA and eptInvOneB $this->assertTrue($a = $this->m->create('eptInvOneManyA')); $this->assertTrue($b = $this->m->create('eptInvOneManyB')); // set $a to $b->a $b->a = $a; $this->assertTrue($b->a === $a); $this->assertTrue($a->bs->inArray($b)); // keep the dump string of the objects $this->assertTrue($a_str = $a->__toString()); $this->assertTrue($b_str = $b->__toString()); // put $a1 and $b1 into an array $array = array($a, $b); $this->assertTrue(count($array) == 2); // --- serailize array --- $this->assertTrue($serialized = serialize($array)); // --- unserailize array --- $this->assertTrue($array_unserialized = unserialize($serialized)); // make sure two objects only $this->assertTrue(count($array_unserialized) == 2); // get a and b $this->assertTrue($a_u = $array_unserialized[0]); $this->assertTrue($b_u = $array_unserialized[1]); // check if association is kept $this->assertTrue($b_u->a === $a_u); $this->assertTrue($a_u->bs->inArray($b_u)); // check if string dump matches $this->assertTrue($a_u->__toString() == $a_str); $this->assertTrue($b_u->__toString() == $b_str); }