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 initSocialSecurity()
 {
     $number = new SocialSecurityForTest();
     $number->setCode(rand(0, 1000));
     return $number;
 }
 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());
 }