コード例 #1
0
 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'));
 }
コード例 #2
0
 function testChangingChildIdRelationFieldDirectlyHasNoAffectIfChildObjectPropertyIsDirty()
 {
     $person = $this->creator->initPerson();
     $number1 = $this->creator->initSocialSecurity();
     $person->setSocialSecurity($number1);
     $person->save();
     $number2 = $this->creator->initSocialSecurity();
     $number2->save();
     $person2 = new PersonForTest($person->getId());
     $this->assertEqual($person2->getSocialSecurity()->getId(), $number1->getId());
     $person2->set('ss_id', $number2->getId());
     // changing child relation field directly
     $person2->setSocialSecurity($number1);
     // and making child object dirty
     $person2->save();
     $person3 = new PersonForTest($person->getId());
     $this->assertEqual($person3->getSocialSecurity()->getId(), $number1->getId());
 }
コード例 #3
0
 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());
 }