当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_DAO::createTestObject方法代码示例

本文整理汇总了PHP中CRM_Core_DAO::createTestObject方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO::createTestObject方法的具体用法?PHP CRM_Core_DAO::createTestObject怎么用?PHP CRM_Core_DAO::createTestObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_DAO的用法示例。


在下文中一共展示了CRM_Core_DAO::createTestObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUp

 function setUp()
 {
     parent::setUp();
     $baoObj = new CRM_Core_DAO();
     $baoObj->createTestObject('CRM_Pledge_BAO_Pledge', array(), 1, 0);
     $baoObj->createTestObject('CRM_Core_BAO_Phone', array(), 1, 0);
     $this->hookClass = CRM_Utils_Hook::singleton();
     $config = CRM_Core_Config::singleton();
     $config->userPermissionClass->permissions = array();
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:10,代码来源:ACLPermissionTest.php

示例2: setUp

 /**
  * Set up permissions for test.
  */
 public function setUp()
 {
     $this->useTransaction(TRUE);
     parent::setUp();
     $individualID = $this->individualCreate();
     $daoObj = new CRM_Core_DAO();
     $this->callAPISuccess('Attachment', 'create', array('entity_table' => 'civicrm_contact', 'entity_id' => $individualID, 'mime_type' => 'k', 'name' => 'p', 'content' => 'l'));
     $daoObj->createTestObject('CRM_Activity_BAO_Activity', array(), 1, 0);
     $daoObj->createTestObject('CRM_Case_BAO_Case', array(), 1, 0);
     $entities = $this->getTagOptions();
     foreach ($entities as $key => $entity) {
         $this->callAPISuccess('Tag', 'create', array('used_for' => $key, 'name' => $entity, 'description' => $entity));
     }
     CRM_Core_Config::singleton()->userPermissionClass->permissions = array('access CiviCRM');
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:18,代码来源:EntityTagACLTest.php

示例3: testGet

 public function testGet()
 {
     $testObject = CRM_Core_DAO::createTestObject('CRM_Booking_DAO_ResourceConfigOption')->toArray();
     $configOption = $this->callAPISuccess('ResourceConfigOption', 'Create', $testObject);
     $result = $this->callAPISuccess('ResourceConfigOption', 'Get', array('id' => $configOption['id'], 'sequential' => 1));
     $this->assertEquals(1, $result['count']);
     $this->assertEquals($testObject['id'], $result['id']);
 }
开发者ID:sushantpaste,项目名称:civibooking,代码行数:8,代码来源:ResourceConfigOptionTest.php

示例4: setUp

 function setUp()
 {
     $this->_apiversion = 3;
     parent::setUp();
     $this->quickCleanup(array('civicrm_msg_template'));
     $template = CRM_Core_DAO::createTestObject('CRM_Core_DAO_MessageTemplate')->toArray();
     $this->params = array('msg_title' => $template['msg_title'], 'msg_subject' => $template['msg_subject'], 'msg_text' => $template['msg_text'], 'msg_html' => $template['msg_html'], 'workflow_id' => $template['workflow_id'], 'is_default' => $template['is_default'], 'is_reserved' => $template['is_reserved'], 'pdf_format_id' => $template['pdf_format_id']);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:8,代码来源:MessageTemplateTest.php

示例5: setUp

 public function setUp()
 {
     $this->_apiversion = 3;
     parent::setUp();
     $this->useTransaction(TRUE);
     $template = CRM_Core_DAO::createTestObject('CRM_Core_DAO_MessageTemplate')->toArray();
     $this->params = array('msg_title' => $template['msg_title'], 'msg_subject' => $template['msg_subject'], 'msg_text' => $template['msg_text'], 'msg_html' => $template['msg_html'], 'workflow_id' => $template['workflow_id'], 'is_default' => $template['is_default'], 'is_reserved' => $template['is_reserved']);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:8,代码来源:MessageTemplateTest.php

示例6: testActivityTarget

 /**
  * Tests CRM_Volunteer_BAO_Assignment::createVolunteerActivity() to ensure
  * that the project beneficiary is made the activity target.
  */
 function testActivityTarget()
 {
     $beneficiaryContactId = $need = $project = $volunteerContactId = NULL;
     extract($this->setUpProject(), EXTR_IF_EXISTS);
     $projectContact = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_ProjectContact', array('contact_id' => $beneficiaryContactId, 'project_id' => $project->id, 'relationship_type_id' => CRM_Core_OptionGroup::getValue('volunteer_project_relationship', 'volunteer_beneficiary', 'name')));
     $this->assertObjectHasAttribute('id', $projectContact, 'Failed to prepopulate VolunteerContact');
     $assignmentId = CRM_Volunteer_BAO_Assignment::createVolunteerActivity(array('assignee_contact_id' => $volunteerContactId, 'source_contact_id' => $volunteerContactId, 'volunteer_need_id' => $need->id));
     $targetContactId = civicrm_api3('ActivityContact', 'getvalue', array('activity_id' => $assignmentId, 'record_type_id' => 'Activity Targets', 'return' => 'contact_id'));
     $this->assertEquals($beneficiaryContactId, $targetContactId);
 }
开发者ID:RussellAult,项目名称:org.civicrm.volunteer,代码行数:14,代码来源:AssignmentTest.php

示例7: testGetProjectContactById

 /**
  * Test simple get via API
  */
 function testGetProjectContactById()
 {
     $relTypeId = CRM_Core_OptionGroup::getValue(CRM_Volunteer_BAO_ProjectContact::RELATIONSHIP_OPTION_GROUP, 'volunteer_owner', 'name');
     $relTypeLabel = CRM_Core_OptionGroup::getLabel(CRM_Volunteer_BAO_ProjectContact::RELATIONSHIP_OPTION_GROUP, $relTypeId);
     $dao = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_ProjectContact', array('relationship_type_id' => $relTypeId));
     $this->assertObjectHasAttribute('id', $dao, 'Failed to prepopulate Volunteer Project Contact');
     $api = $this->callAPIAndDocument('VolunteerProjectContact', 'get', array('id' => $dao->id), __FUNCTION__, __FILE__);
     // make sure the label and machine name are returned
     $vpc = $api['values'][1];
     $this->assertEquals('volunteer_owner', $vpc['relationship_type_name']);
     $this->assertEquals($relTypeLabel, $vpc['relationship_type_label']);
 }
开发者ID:adam-edison,项目名称:org.civicrm.volunteer,代码行数:15,代码来源:VolunteerProjectContactTest.php

示例8: testGetGroupId

 /**
  * Test case for getGroupId( )
  */
 public function testGetGroupId()
 {
     //creates a test groupContact object
     //force group_id to 1 so we can compare
     $groupContact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_GroupContact');
     //check the group contact id is not null
     $this->assertNotNull($groupContact->id);
     $groupId = CRM_Core_DAO::singleValueQuery('select max(id) from civicrm_group');
     $this->assertEquals($groupContact->group_id, $groupId, 'Check for group_id');
     //cleanup
     $groupContact->deleteTestObjects('CRM_Contact_DAO_GroupContact');
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:15,代码来源:GroupContactTest.php

示例9: testGetChain

 public function testGetChain()
 {
     $set = $this->callAPISuccess('ResourceConfigSet', 'Create', array("title" => "title_1", "weight" => 1, "is_enabled" => 1, "is_deleted" => 0));
     $this->callAPISuccess('ResourceConfigOption', 'Create', array("set_id" => $set['id'], "label" => "label_3", "price" => 20.0, "max_size" => "max_size_3", "unit_id" => "unit_id_3", "weight" => 3, "is_enabled" => 1));
     $this->callAPISuccess('ResourceConfigOption', 'Create', array("set_id" => $set['id'], "label" => "label_4", "price" => 30.0, "max_size" => "max_size_4", "unit_id" => "unit_id_4", "weight" => 3, "is_enabled" => 1));
     $testObject = CRM_Core_DAO::createTestObject('CRM_Booking_DAO_Resource')->toArray();
     $params = array('set_id' => $set['id'], 'label' => $testObject['label'], 'description' => $testObject['description'], 'weight' => $testObject['weight'], 'resource_type' => $testObject['resource_type'], 'resource_location' => $testObject['resource_location'], 'is_unlimited' => 0, 'is_enabled' => 1, 'is_deleted' => 0);
     $resource = $this->callAPISuccess('Resource', 'Create', $params);
     $result = $this->callAPISuccess('Resource', 'Get', array('id' => $resource['id'], 'sequential' => 1, 'api.resource_config_set.get' => array('id' => '$value.set_id', 'api.resource_config_option.get' => array('set_id' => '$value.id'))));
     $this->assertEquals(1, $result['count']);
     $this->assertEquals(1, $result['values'][0]['api.resource_config_set.get']['count']);
     $this->assertEquals(2, $result['values'][0]['api.resource_config_set.get']['values'][0]['api.resource_config_option.get']['count']);
 }
开发者ID:sushantpaste,项目名称:civibooking,代码行数:13,代码来源:ResourceTest.php

示例10: testCampaignInheritance

 /**
  * VOL-154: Verifies that an activity created in a project is tagged with the
  * project's campaign.
  */
 function testCampaignInheritance()
 {
     // begin setup
     $campaign = CRM_Core_DAO::createTestObject('CRM_Campaign_BAO_Campaign');
     $this->assertObjectHasAttribute('id', $campaign, 'Failed to prepopulate Campaign');
     $project = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_Project', array('campaign_id' => $campaign->id));
     $this->assertObjectHasAttribute('id', $project, 'Failed to prepopulate Volunteer Project');
     $need = CRM_Core_DAO::createTestObject('CRM_Volunteer_BAO_Need', array('project_id' => $project->id));
     $this->assertObjectHasAttribute('id', $need, 'Failed to prepopulate Volunteer Need');
     // end setup
     $activityId = CRM_Volunteer_BAO_Assignment::createVolunteerActivity(array('assignee_contact_id' => 1, 'source_contact_id' => 1, 'volunteer_need_id' => $need->id));
     $this->assertNotSame(FALSE, $activityId, 'Failed to create Volunteer Activity');
     $createdActivity = CRM_Volunteer_BAO_Assignment::findById($activityId);
     $this->assertEquals($campaign->id, $createdActivity->campaign_id, 'Activity did not inherit campaign from volunteer project');
 }
开发者ID:adam-edison,项目名称:org.civicrm.volunteer,代码行数:19,代码来源:AssignmentTest.php

示例11: testCrossOver

 public function testCrossOver()
 {
     $domain = \CRM_Core_DAO::createTestObject('CRM_Core_DAO_Domain');
     $contact = \CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact');
     $manager = $this->createManager()->useDefaults();
     // Store different values for the 'monkeywrench' setting on domain and contact
     $domainSettings = $manager->getBagByDomain($domain->id);
     $domainSettings->set('monkeywrench', 'from domain');
     $this->assertEquals('from domain', $domainSettings->get('monkeywrench'));
     $contactSettings = $manager->getBagByContact($domain->id, $contact->id);
     $contactSettings->set('monkeywrench', 'from contact');
     $this->assertEquals('from contact', $contactSettings->get('monkeywrench'));
     // Read settings from freshly initialized objects.
     $manager = $this->createManager()->useDefaults();
     $domainSettings = $manager->getBagByDomain($domain->id);
     $this->assertEquals('from domain', $domainSettings->get('monkeywrench'));
     $contactSettings = $manager->getBagByContact($domain->id, $contact->id);
     $this->assertEquals('from contact', $contactSettings->get('monkeywrench'));
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:19,代码来源:SettingsManagerTest.php

示例12: testReplace

 public function testReplace()
 {
     // create an example role
     $role = CRM_Core_DAO::createTestObject('CRM_HRJob_DAO_HRJobRole')->toArray();
     $this->assertTrue(is_numeric($role['id']));
     $this->assertTrue(is_numeric($role['job_id']));
     $this->assertNotEmpty($role['title']);
     $this->assertNotEmpty($role['location']);
     // replace the role
     $result = $this->callAPISuccess('HRJobRole', 'replace', array('job_id' => $role['job_id'], 'values' => array(array('id' => $role['id'], 'job_id' => $role['job_id'], 'description' => 'new description', 'location' => ''))));
     // check return format
     $this->assertEquals(1, $result['count']);
     foreach ($result['values'] as $roleResult) {
         $this->assertTrue(is_array($roleResult));
         // unspecified are preserved & returned
         $this->assertEquals($role['job_id'], $roleResult['job_id']);
         $this->assertEquals($role['title'], $roleResult['title']);
         // passed in values are updated
         $this->assertEquals('new description', $roleResult['description']);
         $this->assertEquals('', $roleResult['location']);
         // BUG: $roleResult['location'] === 'null'
     }
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:23,代码来源:HRJobRoleTest.php

示例13: testDeletePaymentsZeroId

 /**
  *  Pass Zero Id for a payment deletion for one pledge
  */
 function testDeletePaymentsZeroId()
 {
     $payment = CRM_Core_DAO::createTestObject('CRM_Pledge_BAO_PledgePayment');
     $paymentid = CRM_Pledge_BAO_PledgePayment::deletePayments(0);
     $result = CRM_Pledge_BAO_Pledge::deletePledge($payment->pledge_id);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:9,代码来源:PaymentTest.php

示例14: testCreateAutoGrant

 /**
  * This is a test to check if setting fields one at a time alters other fields.
  *
  * Issues Hit so far =
  * 1) Currency keeps getting reset to USD -  BUT this may be the only enabled currency
  *  - in which case it is valid
  * 2)
  */
 public function testCreateAutoGrant()
 {
     $entityName = $this->_entity;
     $baoString = 'CRM_Grant_BAO_Grant';
     $fields = $this->callAPISuccess($entityName, 'getfields', array('action' => 'create'));
     $fields = $fields['values'];
     $return = array_keys($fields);
     $baoObj = new CRM_Core_DAO();
     $baoObj->createTestObject($baoString, array('currency' => 'USD'), 2, 0);
     $getentities = $this->callAPISuccess($entityName, 'get', array('sequential' => 1, 'return' => $return));
     // lets use first rather than assume only one exists
     $entity = $getentities['values'][0];
     $entity2 = $getentities['values'][1];
     foreach ($fields as $field => $specs) {
         if ($field == 'currency' || $field == 'id') {
             continue;
         }
         switch ($specs['type']) {
             case CRM_Utils_Type::T_DATE:
             case CRM_Utils_Type::T_TIMESTAMP:
                 $entity[$field] = '2012-05-20';
                 break;
             case CRM_Utils_Type::T_STRING:
             case CRM_Utils_Type::T_BLOB:
             case CRM_Utils_Type::T_MEDIUMBLOB:
             case CRM_Utils_Type::T_TEXT:
             case CRM_Utils_Type::T_LONGTEXT:
             case CRM_Utils_Type::T_EMAIL:
                 $entity[$field] = 'New String';
                 break;
             case CRM_Utils_Type::T_INT:
                 // probably created with a 1
                 $entity[$field] = 2;
                 if (!empty($specs['FKClassName'])) {
                     $entity[$field] = empty($entity2[$field]) ? $entity2[$specs]['uniqueName'] : $entity2[$field];
                 }
                 break;
             case CRM_Utils_Type::T_BOOLEAN:
                 // probably created with a 1
                 $entity[$field] = 0;
                 break;
             case CRM_Utils_Type::T_FLOAT:
             case CRM_Utils_Type::T_MONEY:
                 $entity[$field] = 222;
                 break;
             case CRM_Utils_Type::T_URL:
                 $entity[$field] = 'warm.beer.com';
         }
         $updateParams = array('id' => $entity['id'], $field => $entity[$field], 'debug' => 1);
         $update = $this->callAPISuccess($entityName, 'create', $updateParams);
         $this->assertAPISuccess($update, "setting {$field} to {$entity[$field]} in line " . __LINE__);
         $checkParams = array('id' => $entity['id'], 'sequential' => 1);
         $checkEntity = $this->callAPISuccess($entityName, 'getsingle', $checkParams);
         $this->assertAPIArrayComparison((array) $entity, $checkEntity);
     }
     $baoObj->deleteTestObjects($baoString);
     $baoObj->free();
 }
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:66,代码来源:GrantTest.php

示例15: createTestObject

 static function createTestObject($daoName, $params = array(), $numObjects = 1, $createOnly = FALSE)
 {
     static $counter = 0;
     CRM_Core_DAO::$_testEntitiesToSkip = array('CRM_Core_DAO_Worldregion', 'CRM_Core_DAO_StateProvince', 'CRM_Core_DAO_Country', 'CRM_Core_DAO_Domain');
     require_once str_replace('_', DIRECTORY_SEPARATOR, $daoName) . ".php";
     for ($i = 0; $i < $numObjects; ++$i) {
         ++$counter;
         eval('$object   = new ' . $daoName . '( );');
         $fields =& $object->fields();
         foreach ($fields as $name => $value) {
             $dbName = $value['name'];
             $FKClassName = CRM_Utils_Array::value('FKClassName', $value);
             $required = CRM_Utils_Array::value('required', $value);
             if (CRM_Utils_Array::value($dbName, $params) !== NULL && !is_array($params[$dbName])) {
                 $object->{$dbName} = $params[$dbName];
             } elseif ($dbName != 'id') {
                 if ($FKClassName != NULL) {
                     //skip the FK if it is not required
                     // if it's contact id we should create even if not required
                     if (!$required && $dbName != 'contact_id') {
                         continue;
                     }
                     if (in_array($FKClassName, CRM_Core_DAO::$_testEntitiesToSkip)) {
                         $depObject = new $FKClassName();
                         $depObject->find(true);
                     } elseif ($daoName == 'CRM_Member_DAO_MembershipType' && $name == 'member_of_contact_id') {
                         // FIXME: the fields() metadata is not specific enough
                         $depObject = CRM_Core_DAO::createTestObject($FKClassName, array('contact_type' => 'Organization'));
                     } else {
                         //if it is required we need to generate the dependency object first
                         $depObject = CRM_Core_DAO::createTestObject($FKClassName, CRM_Utils_Array::value($dbName, $params, 1));
                     }
                     $object->{$dbName} = $depObject->id;
                     unset($depObject);
                     continue;
                 }
                 $constant = CRM_Utils_Array::value('pseudoconstant', $value);
                 if (!empty($constant)) {
                     $constantOptions = array_keys(CRM_Core_PseudoConstant::getConstant($constant));
                     $object->{$dbName} = $constantOptions[0];
                     continue;
                 }
                 $enum = CRM_Utils_Array::value('enumValues', $value);
                 if (!empty($enum)) {
                     $options = explode(',', $enum);
                     $object->{$dbName} = $options[0];
                     continue;
                 }
                 switch ($value['type']) {
                     case CRM_Utils_Type::T_INT:
                     case CRM_Utils_Type::T_FLOAT:
                     case CRM_Utils_Type::T_MONEY:
                         $object->{$dbName} = $counter;
                         break;
                     case CRM_Utils_Type::T_BOOL:
                     case CRM_Utils_Type::T_BOOLEAN:
                         if (isset($value['default'])) {
                             $object->{$dbName} = $value['default'];
                         } elseif ($value['name'] == 'is_deleted' || $value['name'] == 'is_test') {
                             $object->{$dbName} = 0;
                         } else {
                             $object->{$dbName} = 1;
                         }
                         break;
                     case CRM_Utils_Type::T_DATE:
                     case CRM_Utils_Type::T_TIMESTAMP:
                         $object->{$dbName} = '19700101';
                         break;
                     case CRM_Utils_Type::T_TIME:
                         CRM_Core_Error::fatal('T_TIME shouldnt be used.');
                         //$object->$dbName='000000';
                         //break;
                     //$object->$dbName='000000';
                     //break;
                     case CRM_Utils_Type::T_CCNUM:
                         $object->{$dbName} = '4111 1111 1111 1111';
                         break;
                     case CRM_Utils_Type::T_URL:
                         $object->{$dbName} = 'http://www.civicrm.org';
                         break;
                     case CRM_Utils_Type::T_STRING:
                     case CRM_Utils_Type::T_BLOB:
                     case CRM_Utils_Type::T_MEDIUMBLOB:
                     case CRM_Utils_Type::T_TEXT:
                     case CRM_Utils_Type::T_LONGTEXT:
                     case CRM_Utils_Type::T_EMAIL:
                     default:
                         if (isset($value['enumValues'])) {
                             if (isset($value['default'])) {
                                 $object->{$dbName} = $value['default'];
                             } else {
                                 if (is_array($value['enumValues'])) {
                                     $object->{$dbName} = $value['enumValues'][0];
                                 } else {
                                     $defaultValues = explode(',', $value['enumValues']);
                                     $object->{$dbName} = $defaultValues[0];
                                 }
                             }
                         } else {
                             $object->{$dbName} = $dbName . '_' . $counter;
//.........这里部分代码省略.........
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:DAO.php


注:本文中的CRM_Core_DAO::createTestObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。