function testSavingParentSavesChildAsWell() { $person = new PersonForTest(); $person->setName('Jim'); $number = new SocialSecurityForTest(); $number->setCode('099123'); $person->setSocialSecurity($number); $person->save(); $number->setCode($new_code = '0022112'); $person->save(); $loaded_number = new SocialSecurityForTest($number->getId()); $this->assertEqual($loaded_number->getCode(), $new_code); }
function initPerson() { $person = new PersonForTest(); $person->setName('Person_' . rand(0, 1000)); return $person; }
function testUnsettingOneToOneChildObjectMakesPropertyDirty() { $person = new PersonForTest(); $person->setName('Jim'); $number = new SocialSecurityForTest(); $number->setCode('099123'); $person->setSocialSecurity($number); $person->save(); $person->setSocialSecurity(null); $this->assertTrue($person->isDirtyProperty('social_security')); }
function testImportNullEntityEmptyString() { $person = new PersonForTest(); $person->setName('Jim'); $number = new SocialSecurityForTest(); $number->setCode('099123'); $person->setSocialSecurity($number); $person->save(); $source = array('name' => $person->getName(), 'social_security' => ''); $person2 = clone $person; $person2->import($source); $this->assertEqual($person2->getName(), $person->getName()); $this->assertNull($person2->getSocialSecurity()); }