示例#1
0
 /**
  * Testing the getRelatedObject method.
  *
  * @since 1.2.1
  */
 public function testGetRelatedObject()
 {
     $oneToOneRel = new Relation();
     $oneToOneRel->setRelatedClass('Alpha\\Model\\Person');
     $oneToOneRel->setRelatedClassField('OID');
     $oneToOneRel->setRelatedClassDisplayField('displayName');
     $oneToOneRel->setRelationType('ONE-TO-ONE');
     $oneToOneRel->setValue($this->person->getOID());
     $this->assertEquals($this->person->getDisplayName(), $oneToOneRel->getRelatedObject()->get('displayName'), 'testing the getRelatedObject method');
 }
示例#2
0
 /**
  * Testing the saveAttribute method.
  *
  * @since 1.0
  * @dataProvider getActiveRecordProviders
  */
 public function testSaveAttribute($provider)
 {
     $config = ConfigProvider::getInstance();
     $config->set('db.provider.name', $provider);
     $this->person->save();
     $this->person->saveAttribute('displayName', 'unitTestUserNew');
     $this->assertEquals('unitTestUserNew', $this->person->getDisplayName()->getValue(), 'Testing that the value was set on the object in memory along with saving to the database');
     $person = new Person();
     try {
         $person->loadByAttribute('displayName', 'unitTestUserNew');
         $this->assertEquals('unitTestUserNew', $person->getDisplayName()->getValue(), 'Testing that the value was saved to the database');
     } catch (RecordNotFoundException $e) {
         $this->fail('Failed to load the BO that was updated with the saveAttribute method');
     }
 }