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 testSettingNullDetachesChildObject()
 {
     $person = $this->creator->initPerson();
     $number = $this->creator->initSocialSecurity();
     $person->setSocialSecurity($number);
     $person->save();
     $person->setSocialSecurity(null);
     $person_id = $person->save();
     $person2 = new PersonForTest($person_id);
     $this->assertNull($person2->getSocialSecurity());
     $number2 = new SocialSecurityForTest($number->getId());
     $this->assertEqual($number2->getCode(), $number->getCode());
 }
 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());
 }