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


PHP Contact::createIndividual方法代码示例

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


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

示例1: testAllOpenIDs

 /**
  * AllOpenIDs() method - get all OpenIDs for the given contact
  */
 public function testAllOpenIDs()
 {
     $contactId = Contact::createIndividual();
     $this->assertDBRowExist('CRM_Contact_DAO_Contact', $contactId);
     // create first openid
     $openIdURLOne = "http://test-one-username.civicrm.org/";
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'openid' => $openIdURLOne, 'is_primary' => 1, 'allowed_to_login' => 1);
     $openObjectOne = CRM_Core_BAO_OpenID::add($params);
     $openIdOne = $openObjectOne->id;
     $this->assertDBNotNull('CRM_Core_DAO_OpenID', $openIdURLOne, 'id', 'openid', 'Database check for created OpenID.');
     // create second openid
     $openIdURLTwo = "http://test-two-username.civicrm.org/";
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'openid' => $openIdURLTwo);
     $openObjectTwo = CRM_Core_BAO_OpenID::add($params);
     $openIdTwo = $openObjectTwo->id;
     $this->assertDBNotNull('CRM_Core_DAO_OpenID', $openIdURLTwo, 'id', 'openid', 'Database check for created OpenID.');
     // obtain all openids for the contact
     $openIds = CRM_Core_BAO_OpenID::allOpenIDs($contactId);
     // check number of openids for the contact
     $this->assertEquals(2, count($openIds), 'Checking number of returned open-ids.');
     // check first openid values
     $this->assertEquals($openIdURLOne, $openIds[$openIdOne]['openid'], 'Confirm first openid value.');
     $this->assertEquals(1, $openIds[$openIdOne]['is_primary'], 'Confirm is_primary field value.');
     $this->assertEquals(1, $openIds[$openIdOne]['allowed_to_login'], 'Confirm allowed_to_login field value.');
     // check second openid values
     $this->assertEquals($openIdURLTwo, $openIds[$openIdTwo]['openid'], 'Confirm second openid value.');
     $this->assertEquals(0, $openIds[$openIdTwo]['is_primary'], 'Confirm is_primary field value for second openid.');
     $this->assertEquals(0, $openIds[$openIdTwo]['allowed_to_login'], 'Confirm allowed_to_login field value for second openid.');
     //Contact::delete($contactId);
     $this->contactDelete($contactId);
     $this->assertDBRowNotExist('CRM_Contact_DAO_Contact', $contactId);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:35,代码来源:OpenIDTest.php

示例2: testAllOpenIDs

 /**
  * allOpenIDs() method - get all OpenIDs for the given contact
  */
 function testAllOpenIDs()
 {
     $contactId = Contact::createIndividual();
     // create first openid
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'endpoint_url' => $openid['endpoint_url'], 'claimed_id' => $openid['claimed_id'], 'display_id' => $openid['display_id'], 'is_primary' => 1, 'allowed_to_login' => 1);
     require_once 'CRM/Core/BAO/OpenID.php';
     $openObjectOne = CRM_Core_BAO_OpenID::add($params);
     $openIdOne_id = $openObjectOne->id;
     $this->assertDBCompareValues('CRM_Core_DAO_OpenID', array('id' => $openIdOne_id), $openid);
     // create second openid
     $params = array('contact_id' => $contactId, 'location_type_id' => 1, 'endpoint_url' => $openid_two['endpoint_url'], 'claimed_id' => $openid_two['claimed_id'], 'display_id' => $openid_two['display_id']);
     $openObjectTwo = CRM_Core_BAO_OpenID::add($params);
     $openIdTwo_id = $openObjectTwo->id;
     $this->assertDBCompareValues('CRM_Core_DAO_OpenID', array('id' => $openIdTwo_id), $openid_two);
     // obtain all openids for the contact
     $openIds = CRM_Core_BAO_OpenID::allOpenIDs($contactId);
     // check number of openids for the contact
     $this->assertEquals(count($openIds), 2, 'Checking number of returned OpenIDs.');
     // check first openid values
     $this->assertAttributesEquals($openid, $openIds[$openIdOne_id]);
     $this->assertEquals(1, $openIds[$openIdOne_id]['is_primary'], 'Confirm is_primary field value.');
     $this->assertEquals(1, $openIds[$openIdOne_id]['allowed_to_login'], 'Confirm allowed_to_login field value.');
     // check second openid values
     $this->assertAttributesEquals($openid_two, $openIds[$openIdTwo_id]);
     $this->assertEquals(0, $openIds[$openIdTwo_id]['is_primary'], 'Confirm is_primary field value for second openid.');
     $this->assertEquals(0, $openIds[$openIdTwo_id]['allowed_to_login'], 'Confirm allowed_to_login field value for second openid.');
     Contact::delete($contactId);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:31,代码来源:OpenIDTest.php

示例3: setUp

 /**
  * Test setup for every test.
  *
  * Connect to the database, truncate the tables that will be used
  * and redirect stdin to a temporary file
  */
 public function setUp()
 {
     //  Connect to the database
     parent::setUp();
     require_once 'CiviTest/Contact.php';
     // lets create one contact of each type
     Contact::createIndividual();
     Contact::createHousehold();
     Contact::createOrganisation();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:16,代码来源:CRM11793Test.php

示例4: testAllEmails

 /**
  * AllEmails() method - get all emails for our contact, with primary email first
  */
 public function testAllEmails()
 {
     $contactParams = array('first_name' => 'Alan', 'last_name' => 'Smith', 'email-1' => 'alan.smith1@example.com', 'email-2' => 'alan.smith2@example.com', 'email-3' => 'alan.smith3@example.com');
     $contactId = Contact::createIndividual($contactParams);
     $emails = CRM_Core_BAO_Email::allEmails($contactId);
     $this->assertEquals(count($emails), 3, 'Checking number of returned emails.');
     $firstEmailValue = array_slice($emails, 0, 1);
     $this->assertEquals('alan.smith1@example.com', $firstEmailValue[0]['email'], 'Confirm primary email address value.');
     $this->assertEquals(1, $firstEmailValue[0]['is_primary'], 'Confirm first email address is primary.');
     Contact::delete($contactId);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:14,代码来源:EmailTest.php

示例5: testAllPhones

 /**
  * AllPhones() method - get all Phones for our contact, with primary Phone first
  */
 public function testAllPhones()
 {
     $contactParams = array('first_name' => 'Alan', 'last_name' => 'Smith', 'phone-1' => '(415) 222-1011 x 221', 'phone-2' => '(415) 222-5432');
     $contactId = Contact::createIndividual($contactParams);
     $Phones = CRM_Core_BAO_Phone::allPhones($contactId);
     $this->assertEquals(count($Phones), 2, 'Checking number of returned Phones.');
     $firstPhoneValue = array_slice($Phones, 0, 1);
     // Since we're not passing in a location type to createIndividual above, CRM_Contact_BAO_Contact::createProfileContact uses default location
     // type for first phone and sets that to primary.
     $this->assertEquals('(415) 222-1011 x 221', $firstPhoneValue[0]['phone'], "Confirm primary Phone value ( {$firstPhoneValue[0]['phone']} ).");
     $this->assertEquals(1, $firstPhoneValue[0]['is_primary'], 'Confirm first Phone is primary.');
     Contact::delete($contactId);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:16,代码来源:PhoneTest.php

示例6: testsendMail

 /**
  * test setMail() method
  */
 function testsendMail()
 {
     $this->markTestSkipped('throws fatals');
     $contactId = Contact::createIndividual();
     $params = array('title' => 'Test Cotribution Page', 'contribution_type_id' => $this->_contributionTypeID, 'is_active' => 1);
     require_once 'CRM/Contribute/BAO/ContributionPage.php';
     $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params, $ids);
     $contactId = Contact::createIndividual();
     $ids = array('contribution' => null);
     $params = array('contact_id' => $contactId, 'currency' => 'USD', 'contribution_type_id' => 1, 'contribution_status_id' => 1, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => $contributionpage->id, 'non_deductible_amount' => 0.0, 'total_amount' => 200.0, 'fee_amount' => 5, 'net_amount' => 195, 'trxn_id' => '22ereerwww322323', 'invoice_id' => '22ed39c9e9ee6ef6031621ce0eafe6da70', 'thankyou_date' => '20080522');
     require_once 'CRM/Contribute/BAO/Contribution.php';
     $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
     $params = array('id' => 1, 'title' => test, 'contribution_type_id' => $this->_contributionTypeID, 'payment_processor_id' => 1, 'is_credit_card_only' => 0, 'is_monetary' => 1, 'is_recur' => 0, 'is_pay_later' => 1, 'pay_later_text' => 'I will send payment by check', 'pay_later_receipt' => 'test', 'is_allow_other_amount' => 0, 'is_for_organization' => 0, 'for_organization' => 'I am contributing on behalf of an organization.', 'is_email_receipt' => 1, 'is_active' => 1, 'amount_block_is_active' => 1, 'honor_block_is_active' => 0, 'start_date' => '2009-10-22 11:01:00', 'end_date' => '1970-01-01 00:00:00', 'amount' => array(), 'custom_post_id' => null, 'custom_pre_id' => 1, 'accountingCode' => null, 'footer_text' => 'test', 'contribution_id' => $contribution->id);
     $sendmail = CRM_Contribute_BAO_ContributionPage::sendMail($contactId, &$params, $isTest = false, $returnMessageText = false);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:18,代码来源:ContributionPageTest.php

示例7: setUp

 function setUp()
 {
     parent::setUp();
     $permissionIndividual1Id = Contact::createIndividual();
     $permissionIndividual2Id = Contact::createIndividual();
     $juniorposition = 'Junior Support Specialist ' . substr(sha1(rand()), 0, 7);
     $this->juniorParams = array('position' => $juniorposition, 'location' => 'Headquaters', 'salary' => '$110-$130k/yr', 'description' => 'Answer phone calls and emails from irate customers.', 'benefits' => 'Have a place to park', 'requirements' => 'Pro-actively looks to build cross discipline experience and increase knowledge.', 'application_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'application_profile', 'id', 'name'), 'evaluation_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'evaluation_profile', 'id', 'name'), 'status_id' => '1', 'start_date' => '20140425151100', 'end_date' => '20140426231100', 'permission' => array('manage Applicants', 'administer Vacancy'), 'permission_contact_id' => array($permissionIndividual1Id, $permissionIndividual2Id));
     $this->juniorPosition = CRM_HRRecruitment_BAO_HRVacancy::create($this->juniorParams);
     $juniorposition2 = 'Junior Support Specialist ' . substr(sha1(rand()), 0, 7);
     $this->juniorParams2 = array('position' => $juniorposition2, 'location' => 'Home or Home-Office', 'salary' => '$110-$130k/yr', 'status_id' => '1', 'start_date' => '20140425151100', 'end_date' => '20140426231100');
     $this->juniorPosition2 = CRM_HRRecruitment_BAO_HRVacancy::create($this->juniorParams2);
     $seniorposition = 'Senior Support Specialist ' . substr(sha1(rand()), 0, 7);
     $this->seniorParams = array('position' => $seniorposition, 'location' => 'Headquaters', 'salary' => '$110-$130k/yr', 'description' => 'Answer phone calls and emails from irate customers.', 'benefits' => 'Have a place to park', 'requirements' => 'Pro-actively looks to build cross discipline experience and increase knowledge.', 'application_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'application_profile', 'id', 'name'), 'evaluation_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'evaluation_profile', 'id', 'name'), 'status_id' => '2', 'start_date' => '20140425151100', 'end_date' => '20140426231100', 'permission' => array('manage Applicants', 'administer Vacancy'), 'permission_contact_id' => array($permissionIndividual1Id, $permissionIndividual2Id));
     $this->seniorPosition = CRM_HRRecruitment_BAO_HRVacancy::create($this->seniorParams);
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:15,代码来源:HRSearchVacancyTest.php

示例8: testSetGetValuesYesNoRadio

 /**
  * Test setValues() and getValues() methods with custom field YesNo(Boolean) Radio
  */
 public function testSetGetValuesYesNoRadio()
 {
     $params = array();
     $contactID = Contact::createIndividual();
     //create Custom Group
     $customGroup = Custom::createGroup($params, 'Individual', TRUE);
     //create Custom Field of type YesNo(Boolean) Radio
     $fields = array('groupId' => $customGroup->id, 'dataType' => 'Boolean', 'htmlType' => 'Radio');
     $customField = Custom::createField($params, $fields);
     // Retrieve the field ID for sample custom field 'test_Boolean'
     $params = array('label' => 'test_Boolean');
     $field = array();
     //get field Id
     CRM_Core_BAO_CustomField::retrieve($params, $field);
     $fieldID = $field['id'];
     // valid boolean value '1' for Boolean Radio
     $yesNo = '1';
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => $yesNo);
     $result = CRM_Core_BAO_CustomValueTable::setValues($params);
     $this->assertEquals($result['is_error'], 0, 'Verify that is_error = 0 (success).');
     // Check that the YesNo radio value is stored
     $values = array();
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals($values['is_error'], 0, 'Verify that is_error = 0 (success).');
     $this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the boolean value is stored for contact ' . $contactID);
     // Now set YesNo radio to an invalid boolean value and try to reset
     $badYesNo = '20';
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => $badYesNo);
     $errorScope = CRM_Core_TemporaryErrorScope::useException();
     $message = NULL;
     try {
         $result = CRM_Core_BAO_CustomValueTable::setValues($params);
     } catch (Exception $e) {
         $message = $e->getMessage();
     }
     $errorScope = NULL;
     // Check that an exception has been thrown
     $this->assertNotNull($message, 'Verify than an exception is thrown when bad boolean is passed');
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals($values["custom_{$fieldID}_1"], $yesNo, 'Verify that the date value has NOT been updated for contact ' . $contactID);
     // Cleanup
     Custom::deleteField($customField);
     Custom::deleteGroup($customGroup);
     Contact::delete($contactID);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:50,代码来源:CustomValueTableSetGetTest.php

示例9: testAdd

 /**
  * Add() method (create and update modes)
  */
 public function testAdd()
 {
     $contactId = Contact::createIndividual();
     $params = array();
     $params = array('name' => 'jane.doe', 'provider_id' => 1, 'is_primary' => 1, 'location_type_id' => 1, 'contact_id' => $contactId);
     CRM_Core_BAO_IM::add($params);
     $imId = $this->assertDBNotNull('CRM_Core_DAO_IM', 'jane.doe', 'id', 'name', 'Database check for created IM name.');
     // Now call add() to modify an existing IM
     $params = array();
     $params = array('id' => $imId, 'contact_id' => $contactId, 'provider_id' => 3, 'name' => 'doe.jane');
     CRM_Core_BAO_IM::add($params);
     $isEditIM = $this->assertDBNotNull('CRM_Core_DAO_IM', $imId, 'provider_id', 'id', 'Database check on updated IM provider_name record.');
     $this->assertEquals($isEditIM, 3, 'Verify IM provider_id value is 3.');
     $isEditIM = $this->assertDBNotNull('CRM_Core_DAO_IM', $imId, 'name', 'id', 'Database check on updated IM name record.');
     $this->assertEquals($isEditIM, 'doe.jane', 'Verify IM provider_id value is doe.jane.');
     Contact::delete($contactId);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:20,代码来源:IMTest.php

示例10: testCustomGroupMultipleOldFormate

 public function testCustomGroupMultipleOldFormate()
 {
     $params = array();
     $contactID = Contact::createIndividual();
     $customGroup = Custom::createGroup($params, 'Individual', TRUE);
     $fields = array('groupId' => $customGroup->id, 'dataType' => 'String', 'htmlType' => 'Text');
     $customField = Custom::createField($params, $fields);
     $params = array('entityID' => $contactID, "custom_{$customField->id}" => 'First String');
     $error = CRM_Core_BAO_CustomValueTable::setValues($params);
     $newParams = array('entityID' => $contactID, "custom_{$customField->id}" => 1);
     $result = CRM_Core_BAO_CustomValueTable::getValues($newParams);
     $this->assertEquals($params["custom_{$customField->id}"], $result["custom_{$customField->id}_1"]);
     $this->assertEquals($params['entityID'], $result['entityID']);
     Custom::deleteField($customField);
     Custom::deleteGroup($customGroup);
     Contact::delete($contactID);
 }
开发者ID:sdekok,项目名称:civicrm-core,代码行数:17,代码来源:CustomValueTableMultipleTest.php

示例11: testSetGetValuesYesNoRadio

 function testSetGetValuesYesNoRadio()
 {
     $params = array();
     $contactID = Contact::createIndividual();
     //create Custom Group
     $customGroup = Custom::createGroup($params, 'Individual', true);
     //create Custom Field of type YesNo(Boolean) Radio
     $fields = array('groupId' => $customGroup->id, 'dataType' => 'Boolean', 'htmlType' => 'Radio');
     $customField = Custom::createField($params, $fields);
     // Retrieve the field ID for sample custom field 'test_Boolean'
     $params = array('label' => 'test_Boolean');
     $field = array();
     //get field Id
     require_once 'CRM/Core/BAO/CustomField.php';
     CRM_Core_BAO_CustomField::retrieve($params, $field);
     $fieldID = $field['id'];
     // valid boolean value '1' for Boolean Radio
     $yesNo = '1';
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => $yesNo);
     require_once 'CRM/Core/BAO/CustomValueTable.php';
     $result = CRM_Core_BAO_CustomValueTable::setValues($params);
     $this->assertEquals($result['is_error'], 0, 'Verify that is_error = 0 (success).');
     // Check that the YesNo radio value is stored
     $values = array();
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals($values['is_error'], 0, 'Verify that is_error = 0 (success).');
     $this->assertEquals($values['custom_1_1'], $yesNo, 'Verify that the date value is stored for contact ' . $contactID);
     // Now set YesNo radio to an invalid boolean value and try to reset
     $badYesNo = '20';
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => $badYesNo);
     require_once 'CRM/Core/BAO/CustomValueTable.php';
     $result = CRM_Core_BAO_CustomValueTable::setValues($params);
     // Check that the error flag is set AND that custom date value has not been modified
     $this->assertEquals($result['is_error'], $yesNo, 'Verify that is_error = 1 when bad boolen value is passed.');
     $params = array('entityID' => $contactID, 'custom_' . $fieldID => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals($values['custom_1_1'], $yesNo, 'Verify that the date value has NOT been updated for contact ' . $contactID);
     // Cleanup
     Custom::deleteField($customField);
     Custom::deleteGroup($customGroup);
     Contact::delete($contactID);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:43,代码来源:CustomValueTableSetGetTest.php

示例12: testCreateGet

 /**
  * create() method (create and update modes)
  */
 function testCreateGet()
 {
     $permissionIndividual1Id = Contact::createIndividual();
     $permissionIndividual2Id = Contact::createIndividual();
     $stages = array_keys(CRM_Core_OptionGroup::values('case_status', FALSE, FALSE, FALSE, " AND grouping = 'Vacancy'"));
     $params = array('position' => 'Senior Support Specialist', 'location' => 'Headquaters', 'salary' => '$110-$130k/yr', 'description' => 'Answer phone calls and emails from irate customers.', 'benefits' => 'Have a place to park', 'requirements' => 'Pro-actively looks to build cross discipline experience and increase knowledge.', 'stages' => $stages, 'application_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'application_profile', 'id', 'name'), 'evaluation_profile' => CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', 'evaluation_profile', 'id', 'name'), 'status_id' => '4', 'start_date' => '20140425151100', 'end_date' => '20140426231100', 'permission' => array('manage Applicants', 'administer Vacancy'), 'permission_contact_id' => array($permissionIndividual1Id, $permissionIndividual2Id));
     $vacancy = CRM_HRRecruitment_BAO_HRVacancy::create($params);
     $getValues = array();
     $getParams = array('id' => $vacancy->id);
     CRM_HRRecruitment_BAO_HRVacancy::retrieve($getParams, $getValues);
     //stage array index always starts with 1 so in order to make changes in
     //$getValues['stages'] in order to just match the value
     $getValues['stages'] = array_values($getValues['stages']);
     $getValues['permission'] = array_values($getValues['permission']);
     $getValues['permission_contact_id'] = array_values($getValues['permission_contact_id']);
     //process date back to mysql format
     $getValues['start_date'] = CRM_Utils_Date::isoToMysql($getValues['start_date']);
     $getValues['end_date'] = CRM_Utils_Date::isoToMysql($getValues['end_date']);
     foreach ($params as $column => $value) {
         $this->assertEquals($params[$column], $getValues[$column], "Check for Job {$column}.");
     }
 }
开发者ID:JoeMurray,项目名称:civihr,代码行数:25,代码来源:HRVacancyTest.php

示例13: testContactSearchByParentGroup

 /**
  *  Test case for contact search: CRM-6706, CRM-6586 Parent Group search should return contacts from child groups too.
  */
 public function testContactSearchByParentGroup()
 {
     // create a parent group
     // TODO: This is not an API test!!
     $groupParams1 = array('title' => 'Parent Group', 'description' => 'Parent Group', 'visibility' => 'User and User Admin Only', 'parents' => '', 'is_active' => 1);
     $parentGroup = CRM_Contact_BAO_Group::create($groupParams1);
     // create a child group
     $groupParams2 = array('title' => 'Child Group', 'description' => 'Child Group', 'visibility' => 'User and User Admin Only', 'parents' => $parentGroup->id, 'is_active' => 1);
     $childGroup = CRM_Contact_BAO_Group::create($groupParams2);
     // Create a contact within parent group
     $parentContactParams = array('first_name' => 'Parent1 Fname', 'last_name' => 'Parent1 Lname', 'group' => array($parentGroup->id => 1));
     $parentContact = Contact::createIndividual($parentContactParams);
     // create a contact within child dgroup
     $childContactParams = array('first_name' => 'Child1 Fname', 'last_name' => 'Child2 Lname', 'group' => array($childGroup->id => 1));
     $childContact = Contact::createIndividual($childContactParams);
     // Check if searching by parent group  returns both parent and child group contacts
     $searchParams = array('group' => $parentGroup->id, 'version' => 3);
     $result = civicrm_api('contact', 'get', $searchParams);
     $validContactIds = array($parentContact, $childContact);
     $resultContactIds = array();
     foreach ($result['values'] as $k => $v) {
         $resultContactIds[] = $v['contact_id'];
     }
     $this->assertEquals(2, count($resultContactIds), 'Check the count of returned values');
     $this->assertEquals(array(), array_diff($validContactIds, $resultContactIds), 'Check that the difference between two arrays should be blank array');
     // Check if searching by child group returns just child group contacts
     $searchParams = array('group' => $childGroup->id, 'version' => 3);
     $result = civicrm_api('contact', 'get', $searchParams);
     $validChildContactIds = array($childContact);
     $resultChildContactIds = array();
     foreach ($result['values'] as $k => $v) {
         $resultChildContactIds[] = $v['contact_id'];
     }
     $this->assertEquals(1, count($resultChildContactIds), 'Check the count of returned values');
     $this->assertEquals(array(), array_diff($validChildContactIds, $resultChildContactIds), 'Check that the difference between two arrays should be blank array');
 }
开发者ID:rameshrr99,项目名称:civicrm-core,代码行数:39,代码来源:GroupContactTest.php

示例14: addParticipantWithContribution

 /**
  * Add participant with contribution
  *
  * @return array
  */
 protected function addParticipantWithContribution()
 {
     // creating price set, price field
     require_once 'CiviTest/Event.php';
     $this->_contactId = Contact::createIndividual();
     $this->_eventId = Event::create($this->_contactId);
     $paramsSet['title'] = 'Price Set' . substr(sha1(rand()), 0, 4);
     $paramsSet['name'] = CRM_Utils_String::titleToVar($paramsSet['title']);
     $paramsSet['is_active'] = TRUE;
     $paramsSet['financial_type_id'] = 4;
     $paramsSet['extends'] = 1;
     $priceset = CRM_Price_BAO_PriceSet::create($paramsSet);
     $priceSetId = $priceset->id;
     //Checking for priceset added in the table.
     $this->assertDBCompareValue('CRM_Price_BAO_PriceSet', $priceSetId, 'title', 'id', $paramsSet['title'], 'Check DB for created priceset');
     $paramsField = array('label' => 'Price Field', 'name' => CRM_Utils_String::titleToVar('Price Field'), 'html_type' => 'CheckBox', 'option_label' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_value' => array('1' => 100, '2' => 200), 'option_name' => array('1' => 'Price Field 1', '2' => 'Price Field 2'), 'option_weight' => array('1' => 1, '2' => 2), 'option_amount' => array('1' => 100, '2' => 200), 'is_display_amounts' => 1, 'weight' => 1, 'options_per_line' => 1, 'is_active' => array('1' => 1, '2' => 1), 'price_set_id' => $priceset->id, 'is_enter_qty' => 1, 'financial_type_id' => CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', 'Event Fee', 'id', 'name'));
     $priceField = CRM_Price_BAO_PriceField::create($paramsField);
     $eventParams = array('id' => $this->_eventId, 'financial_type_id' => 4, 'is_monetary' => 1);
     CRM_Event_BAO_Event::create($eventParams);
     CRM_Price_BAO_PriceSet::addTo('civicrm_event', $this->_eventId, $priceSetId);
     $priceFields = $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $priceField->id));
     $participantParams = array('financial_type_id' => 4, 'event_id' => $this->_eventId, 'role_id' => 1, 'status_id' => 14, 'fee_currency' => 'USD', 'contact_id' => $this->_contactId);
     $participant = CRM_Event_BAO_Participant::add($participantParams);
     $contributionParams = array('total_amount' => 150, 'currency' => 'USD', 'contact_id' => $this->_contactId, 'financial_type_id' => 4, 'contribution_status_id' => 1, 'partial_payment_total' => 300.0, 'partial_amount_pay' => 150, 'contribution_mode' => 'participant', 'participant_id' => $participant->id);
     foreach ($priceFields['values'] as $key => $priceField) {
         $lineItems[1][$key] = array('price_field_id' => $priceField['price_field_id'], 'price_field_value_id' => $priceField['id'], 'label' => $priceField['label'], 'field_title' => $priceField['label'], 'qty' => 1, 'unit_price' => $priceField['amount'], 'line_total' => $priceField['amount'], 'financial_type_id' => $priceField['financial_type_id']);
     }
     $contributionParams['line_item'] = $lineItems;
     $contributions = CRM_Contribute_BAO_Contribution::create($contributionParams);
     $paymentParticipant = array('participant_id' => $participant->id, 'contribution_id' => $contributions->id);
     $ids = array();
     CRM_Event_BAO_ParticipantPayment::create($paymentParticipant, $ids);
     return array($lineItems, $contributions);
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:39,代码来源:ContributionTest.php

示例15: testMoveField

 /**
  * Move a custom field from $groupA to $groupB. Make sure that data records are
  * correctly matched and created.
  */
 public function testMoveField()
 {
     $countriesByName = array_flip(CRM_Core_PseudoConstant::country(FALSE, FALSE));
     $this->assertTrue($countriesByName['ANDORRA'] > 0);
     $groups = array('A' => Custom::createGroup(array('title' => 'Test_Group A', 'name' => 'test_group_a', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)), 'B' => Custom::createGroup(array('title' => 'Test_Group B', 'name' => 'test_group_b', 'extends' => array('Individual'), 'style' => 'Inline', 'is_multiple' => 0, 'is_active' => 1, 'version' => 3)));
     $fields = array('countryA' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country A', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryB' => Custom::createField(array(), array('groupId' => $groups['A']->id, 'label' => 'Country B', 'dataType' => 'Country', 'htmlType' => 'Select Country')), 'countryC' => Custom::createField(array(), array('groupId' => $groups['B']->id, 'label' => 'Country C', 'dataType' => 'Country', 'htmlType' => 'Select Country')));
     $contacts = array('alice' => Contact::createIndividual(array('first_name' => 'Alice', 'last_name' => 'Albertson', 'custom_' . $fields['countryA']->id => $countriesByName['ANDORRA'], 'custom_' . $fields['countryB']->id => $countriesByName['BARBADOS'])), 'bob' => Contact::createIndividual(array('first_name' => 'Bob', 'last_name' => 'Roberts', 'custom_' . $fields['countryA']->id => $countriesByName['AUSTRIA'], 'custom_' . $fields['countryB']->id => $countriesByName['BERMUDA'], 'custom_' . $fields['countryC']->id => $countriesByName['CHAD'])), 'carol' => Contact::createIndividual(array('first_name' => 'Carol', 'last_name' => 'Carolson', 'custom_' . $fields['countryC']->id => $countriesByName['CAMBODIA'])));
     // Move!
     CRM_Core_BAO_CustomField::moveField($fields['countryB']->id, $groups['B']->id);
     // Group[A] no longer has fields[countryB]
     $errorScope = CRM_Core_TemporaryErrorScope::useException();
     try {
         $this->assertDBQuery(1, "SELECT {$fields['countryB']->column_name} FROM {$groups['A']->table_name}");
         $this->fail('Expected exception when querying column on wrong table');
     } catch (PEAR_Exception $e) {
     }
     $errorScope = NULL;
     // Alice: Group[B] has fields[countryB], but fields[countryC] did not exist before
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} = %3\n            AND {$fields['countryC']->column_name} is null", array(1 => array($contacts['alice'], 'Integer'), 3 => array($countriesByName['BARBADOS'], 'Integer')));
     // Bob: Group[B] has merged fields[countryB] and fields[countryC] on the same record
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} = %3\n            AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['bob'], 'Integer'), 3 => array($countriesByName['BERMUDA'], 'Integer'), 4 => array($countriesByName['CHAD'], 'Integer')));
     // Carol: Group[B] still has fields[countryC] but did not get fields[countryB]
     $this->assertDBQuery(1, "SELECT count(*) FROM {$groups['B']->table_name}\n            WHERE entity_id = %1\n            AND {$fields['countryB']->column_name} is null\n            AND {$fields['countryC']->column_name} = %4", array(1 => array($contacts['carol'], 'Integer'), 4 => array($countriesByName['CAMBODIA'], 'Integer')));
     Custom::deleteGroup($groups['A']);
     Custom::deleteGroup($groups['B']);
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:30,代码来源:CustomFieldTest.php


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