Exemple #1
0
 public function modelRelationMap()
 {
     return ['customerAttributes' => array('type' => 'hasEav', 'class' => CustomerAttributes::className(), 'link' => array('objectId' => 'id'), 'onSaveAll' => ActiveRecord::SAVE_CASCADE, 'onDeleteFull' => ActiveRecord::DELETE_CASCADE, 'autoLinkType' => ActiveRecord::LINK_FROM_PARENT_MAINT, 'allToArray' => true, 'activeAttributesInParent' => true), 'address' => array('type' => 'hasOne', 'class' => Address::className(), 'link' => array('id' => 'addressId'), 'onSaveAll' => ActiveRecord::SAVE_CASCADE, 'onDeleteFull' => ActiveRecord::DELETE_CASCADE, 'autoLinkType' => ActiveRecord::LINK_BI_DIRECT_MAINT_FROM_PARENT, 'autoLink' => array('fromParent' => array('customerId' => 'id'), 'fromChild' => array('id' => 'addressId')), 'allToArray' => true), 'phone' => array('type' => 'hasOne', 'class' => Phone::className(), 'link' => array('id' => 'phoneId'), 'onSaveAll' => ActiveRecord::SAVE_CASCADE, 'onDeleteFull' => ActiveRecord::DELETE_CASCADE, 'autoLinkType' => ActiveRecord::LINK_BI_DIRECT_MAINT_FROM_PARENT, 'autoLink' => array('fromParent' => array('customerId' => 'id'), 'fromChild' => array('id' => 'phoneId')), 'allToArray' => true), 'orders' => array('type' => 'hasMany', 'class' => Order::className(), 'link' => array('customerId' => 'id'), 'onSaveAll' => ActiveRecord::SAVE_CASCADE, 'onDeleteFull' => ActiveRecord::DELETE_CASCADE, 'autoLinkType' => ActiveRecord::LINK_FROM_PARENT_MAINT, 'allToArray' => true)];
 }
 /**
  * Test setValuesByArray method
  */
 public function testSetValuesByArray()
 {
     $client = Client::findOne(1);
     $this->assertInstanceOf(Client::className(), $client);
     $this->setService('client', $client);
     $customerAttributes = new CustomerAttributes();
     $customerAttributes->setValuesByArray(array('field1' => 'a', 'field2' => 'b'), array('modifiedBy' => 54));
     $this->assertEquals('a', $customerAttributes->field1);
     $this->assertEquals('b', $customerAttributes->field2);
     $this->assertEquals(54, $customerAttributes->modifiedBy);
 }