Exemplo n.º 1
0
 /**
  * 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);
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
 /**
  * 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();
 }
Exemplo n.º 4
0
 /**
  * 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' => '*****@*****.**', 'email-2' => '*****@*****.**', 'email-3' => '*****@*****.**');
     $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('*****@*****.**', $firstEmailValue[0]['email'], 'Confirm primary email address value.');
     $this->assertEquals(1, $firstEmailValue[0]['is_primary'], 'Confirm first email address is primary.');
     Contact::delete($contactId);
 }
Exemplo n.º 5
0
 /**
  * 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);
 }
Exemplo n.º 6
0
 /**
  * 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);
 }
Exemplo n.º 7
0
 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);
 }
 /**
  * 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);
 }
Exemplo n.º 9
0
 /**
  * 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);
 }
 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);
 }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
 /**
  * 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}.");
     }
 }
Exemplo n.º 13
0
 /**
  *  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');
 }
Exemplo n.º 14
0
 /**
  * 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);
 }
Exemplo n.º 15
0
 /**
  * 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']);
 }
Exemplo n.º 16
0
 /**
  * test logged in user has permissions for 
  * various  operation types
  */
 function testPermissionedContact()
 {
     $contactId = Contact::createIndividual();
     require_once 'CRM/Contact/BAO/Contact/Permission.php';
     $userViewPermission = CRM_Contact_BAO_Contact_Permission::allow($contactId);
     $this->assertEquals($userViewPermission, true, 'Check user for view contact permission.');
     $userEditPermission = CRM_Contact_BAO_Contact_Permission::allow($contactId, CRM_Core_Permission::EDIT);
     $this->assertEquals($userEditPermission, true, 'Check user for edit contact permission.');
     Contact::delete($contactId);
 }
Exemplo n.º 17
0
 /**
  * GetValues() method (get Address fields)
  */
 public function testGetValues()
 {
     $contactId = Contact::createIndividual();
     $params = array();
     $params['address']['1'] = array('street_address' => 'Oberoi Garden', 'supplemental_address_1' => 'Attn: Accounting', 'supplemental_address_2' => 'Powai', 'city' => 'Athens', 'postal_code' => '01903', 'state_province_id' => '1000', 'country_id' => '1228', 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973', 'location_type_id' => '1', 'is_primary' => '1', 'is_billing' => '0');
     $params['contact_id'] = $contactId;
     $fixAddress = TRUE;
     CRM_Core_BAO_Address::create($params, $fixAddress, $entity = NULL);
     $addressId = $this->assertDBNotNull('CRM_Core_DAO_Address', $contactId, 'id', 'contact_id', 'Database check for created address.');
     $entityBlock = array('contact_id' => $contactId);
     $address = CRM_Core_BAO_Address::getValues($entityBlock);
     $this->assertEquals($address[1]['id'], $addressId);
     $this->assertEquals($address[1]['contact_id'], $contactId);
     $this->assertEquals($address[1]['street_address'], 'Oberoi Garden');
     Contact::delete($contactId);
 }
Exemplo n.º 18
0
 /**
  *  Test resetmodified()
  */
 public function testresetmodifiedId()
 {
     $contactId = Contact::createIndividual();
     $params = array('contact_id' => $contactId, 'membership_type_id' => $this->_membershipTypeID, 'join_date' => date('Ymd', strtotime('2006-01-21')), 'start_date' => date('Ymd', strtotime('2006-01-21')), 'end_date' => date('Ymd', strtotime('2006-12-21')), 'source' => 'Payment', 'is_override' => 1, 'status_id' => $this->_mebershipStatusID);
     $ids = array('userId' => $contactId);
     $membership = CRM_Member_BAO_Membership::create($params, $ids);
     $resetModifiedId = CRM_Member_BAO_MembershipLog::resetModifiedID($contactId);
     $this->assertDBNull('CRM_Member_BAO_MembershipLog', $contactId, 'modified_id', 'modified_id', 'Database check for NULL modified id.');
     $this->membershipDelete($membership->id);
     $this->contactDelete($contactId);
 }
Exemplo n.º 19
0
 /**
  * Check duplicate contribution id 
  * during the contribution import
  * checkDuplicateIds();
  */
 function testcheckDuplicateIds()
 {
     $contactId = Contact::createIndividual();
     $ids = array('contribution' => null);
     $param = 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' => null, 'non_deductible_amount' => 0.0, 'total_amount' => 300.0, 'fee_amount' => 5, 'net_amount' => 295, 'trxn_id' => '22ereerwww323', 'invoice_id' => '22ed39c9e9ee621ce0eafe6da70', 'thankyou_date' => '20080522');
     require_once 'CRM/Contribute/BAO/Contribution.php';
     $contribution = CRM_Contribute_BAO_Contribution::create($param, $ids);
     $this->assertEquals($param['trxn_id'], $contribution->trxn_id, 'Check for transcation id creation.');
     $this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id  creation.');
     $data = array('id' => $contribution->id, 'trxn_id' => $contribution->trxn_id, 'invoice_id' => $contribution->invoice_id);
     $contributionID = CRM_Contribute_BAO_Contribution::checkDuplicateIds($data);
     $this->assertEquals($contributionID, $contribution->id, 'Check for duplicate transcation id .');
     Contact::delete($contactId);
 }
 /**
  * Test civicrm_membershipcontributionlink_get - success expected.
  */
 public function testGet()
 {
     $contactId = Contact::createIndividual();
     $params = array('contact_id' => $contactId, 'currency' => 'USD', 'contribution_type_id' => $this->_contributionTypeID, 'contribution_status_id' => 1, 'contribution_page_id' => null, 'payment_instrument_id' => 1, 'id' => null, 'total_amount' => 200.0);
     require_once 'CRM/Contribute/BAO/Contribution.php';
     $contribution = CRM_Contribute_BAO_Contribution::create($params, $ids);
     $params = array('contact_id' => $contactId, 'membership_type_id' => $this->_membershipTypeID, 'source' => 'Payment', 'is_override' => 1, 'status_id' => $this->_membershipStatusID);
     $ids = array();
     $membership = CRM_Member_BAO_Membership::create($params, $ids);
     $params = array('contribution_id' => $contribution->id, 'membership_id' => $membership->id);
     $Create = civicrm_membershipcontributionlink_create($params);
     $GetParams = civicrm_membershipcontributionlink_get(&$params);
     $this->assertEquals($GetParams[$Create['id']]['membership_id'], $membership->id, 'Check Membership Id');
     $this->assertEquals($GetParams[$Create['id']]['contribution_id'], $contribution->id, 'Check Contribution Id');
 }
 /**
  * Check method testcheckPermissionedLineItems()
  */
 public function testcheckPermissionedLineItems()
 {
     $contactId = Contact::createIndividual();
     $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'] = 1;
     $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' => 1);
     $priceField = CRM_Price_BAO_PriceField::create($paramsField);
     $priceFields = $this->callAPISuccess('PriceFieldValue', 'get', array('price_field_id' => $priceField->id));
     $contributionParams = array('total_amount' => 300, 'currency' => 'USD', 'contact_id' => $contactId, 'financial_type_id' => 1, 'contribution_status_id' => 1);
     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);
     CRM_Financial_BAO_FinancialType::$_statusACLFt = array();
     $this->setACL();
     $this->setPermissions(array('view contributions of type Member Dues'));
     try {
         CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributions->id, 'view');
         $this->fail("Missed expected exception");
     } catch (Exception $e) {
         $this->assertEquals("A fatal error was triggered: You do not have permission to access this page.", $e->getMessage());
     }
     $this->setPermissions(array('view contributions of type Donation'));
     $perm = CRM_Financial_BAO_FinancialType::checkPermissionedLineItems($contributions->id, 'view');
     $this->assertEquals($perm, TRUE, 'Verify that lineitems now have permission.');
 }
Exemplo n.º 22
0
 /**
  * Renew stale membership.
  */
 public function testStaleMembership()
 {
     $statusId = 3;
     $contactId = Contact::createIndividual();
     $joinDate = $startDate = date("Ymd", strtotime(date("Ymd") . " -1 year -15 days"));
     $endDate = date("Ymd", strtotime($joinDate . " +1 year -1 day"));
     $params = array('contact_id' => $contactId, 'membership_type_id' => $this->_membershipTypeID, 'join_date' => $joinDate, 'start_date' => $startDate, 'end_date' => $endDate, 'source' => 'Payment', 'status_id' => $statusId);
     $ids = array();
     $membership = CRM_Member_BAO_Membership::create($params, $ids);
     $membershipId = $this->assertDBNotNull('CRM_Member_BAO_Membership', $contactId, 'id', 'contact_id', 'Database check for created membership.');
     $this->assertEquals($membership->status_id, $statusId, 'Verify correct status id is calculated.');
     $this->assertEquals($membership->membership_type_id, $this->_membershipTypeID, 'Verify correct membership type id.');
     //verify all dates.
     $dates = array('startDate' => 'start_date', 'joinDate' => 'join_date', 'endDate' => 'end_date');
     foreach ($dates as $date => $dbDate) {
         $this->assertEquals($membership->{$dbDate}, ${$date}, "Verify correct {$date} is present.");
     }
     $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $membership->id, 'id', 'membership_id', 'Database checked on membershiplog record.');
     // this is a test and we dont want qfKey generation / validation
     // easier to suppress it, than change core code
     $config = CRM_Core_Config::singleton();
     $config->keyDisable = TRUE;
     $membershipRenewal = new CRM_Core_Form();
     $membershipRenewal->controller = new CRM_Core_Controller();
     list($MembershipRenew) = CRM_Member_BAO_Membership::renewMembership($contactId, $this->_membershipTypeID, FALSE, $membershipRenewal, NULL, NULL, NULL, 1, NULL, NULL, NULL, FALSE, NULL);
     $this->assertDBNotNull('CRM_Member_BAO_MembershipLog', $MembershipRenew->id, 'id', 'membership_id', 'Database checked on membershiplog record.');
     $this->membershipDelete($membershipId);
     Contact::delete($contactId);
 }
Exemplo n.º 23
0
 /**
  * Check credit note id creation
  * when a contribution is cancelled or refunded
  * createCreditNoteId();
  */
 public function testCreateCreditNoteId()
 {
     $contactId = Contact::createIndividual();
     $ids = array('contribution' => NULL);
     $param = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 1, 'contribution_status_id' => 3, 'payment_instrument_id' => 1, 'source' => 'STUDENT', 'receive_date' => '20080522000000', 'receipt_date' => '20080522000000', 'id' => NULL, 'non_deductible_amount' => 0.0, 'total_amount' => 300.0, 'fee_amount' => 5, 'net_amount' => 295, 'trxn_id' => '76ereeswww835', 'invoice_id' => '93ed39a9e9hd621bs0eafe3da82', 'thankyou_date' => '20080522');
     $creditNoteId = CRM_Contribute_BAO_Contribution::createCreditNoteId();
     $contribution = CRM_Contribute_BAO_Contribution::create($param, $ids);
     $this->assertEquals($contactId, $contribution->contact_id, 'Check for contact id  creation.');
     $this->assertEquals($creditNoteId, $contribution->creditnote_id, 'Check if credit note id is created correctly.');
     // Delete Contribution
     $this->contributionDelete($contribution->id);
     // Delete Contact
     Contact::delete($contactId);
 }
Exemplo n.º 24
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     parent::setUp();
     $this->_contactId = Contact::createIndividual();
 }
Exemplo n.º 25
0
 function testGetActiveGroups()
 {
     $contactId = Contact::createIndividual();
     $customGrouptitle = 'Test Custom Group';
     $groupParams = array('title' => $customGrouptitle, 'name' => 'test_custom_group', 'style' => 'Tab', 'extends' => 'Individual', 'weight' => 10, 'is_active' => 1);
     $customGroup = Custom::createGroup($groupParams);
     require_once 'CRM/Core/BAO/CustomGroup.php';
     $activeGroup = CRM_Core_BAO_CustomGroup::getActiveGroups('Individual', 'civicrm/contact/view/cd', $contactId);
     foreach ($activeGroup as $key => $value) {
         if ($value['id'] == $customGroup->id) {
             $this->assertEquals($value['path'], 'civicrm/contact/view/cd');
             $this->assertEquals($value['title'], $customGrouptitle);
             $query = 'reset=1&gid=' . $customGroup->id . '&cid=' . $contactId;
             $this->assertEquals($value['query'], $query);
         }
     }
     Custom::deleteGroup($customGroup);
     Contact::delete($contactId);
 }
Exemplo n.º 26
0
 /**
  * Helper for testing timestamp manipulation.
  *
  * Create a contact and perform a series of steps with it; after each
  * step, ensure that the contact's modified_date has increased.
  *
  * @param array $callbacks
  *   ($name => $callable).
  */
 public function _testTimestamps($callbacks)
 {
     CRM_Core_DAO::triggerRebuild();
     $contactId = Contact::createIndividual();
     $origTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId);
     $this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $origTimestamps['created_date']);
     $this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $origTimestamps['modified_date']);
     $this->assertTrue($origTimestamps['created_date'] <= $origTimestamps['modified_date']);
     $prevTimestamps = $origTimestamps;
     foreach ($callbacks as $callbackName => $callback) {
         sleep(1);
         // advance clock by 1 second to ensure timestamps change
         $callback($contactId);
         $newTimestamps = CRM_Contact_BAO_Contact::getTimestamps($contactId);
         $this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $newTimestamps['created_date'], "Malformed created_date (after {$callbackName})");
         $this->assertRegexp('/^\\d\\d\\d\\d-\\d\\d-\\d\\d /', $newTimestamps['modified_date'], "Malformed modified_date (after {$callbackName})");
         $this->assertEquals($origTimestamps['created_date'], $newTimestamps['created_date'], "Changed created_date (after {$callbackName})");
         $this->assertTrue($prevTimestamps['modified_date'] < $newTimestamps['modified_date'], "Misordered modified_date (after {$callbackName})");
         $prevTimestamps = $newTimestamps;
     }
     Contact::delete($contactId);
 }
Exemplo n.º 27
0
 /**
  * getValues() method
  * get the values of various location elements 
  */
 function testLocBlockgetValues()
 {
     $contactId = Contact::createIndividual();
     //create various element of location block
     //like address, phone, email, openid, im.
     $params = array('address' => array('1' => array('street_address' => 'Saint Helier St', 'supplemental_address_1' => 'Hallmark Ct', 'supplemental_address_2' => 'Jersey Village', 'city' => 'Newark', 'postal_code' => '01903', 'country_id' => 1228, 'state_province_id' => 1029, 'geo_code_1' => '18.219023', 'geo_code_2' => '-105.00973', 'is_primary' => 1, 'location_type_id' => 1)), 'email' => array('1' => array('email' => '*****@*****.**', 'is_primary' => 1, 'location_type_id' => 1)), 'phone' => array('1' => array('phone_type_id' => 1, 'phone' => '303443689', 'is_primary' => 1, 'location_type_id' => 1), '2' => array('phone_type_id' => 2, 'phone' => '9833910234', 'location_type_id' => 1)), 'openid' => array('1' => array('openid' => 'http://civicrm.org/', 'location_type_id' => 1, 'is_primary' => 1)), 'im' => array('1' => array('name' => 'jane.doe', 'provider_id' => 1, 'location_type_id' => 1, 'is_primary' => 1)));
     $params['contact_id'] = $contactId;
     //create location elements.
     require_once 'CRM/Core/BAO/Location.php';
     CRM_Core_BAO_Location::create($params);
     //get the values from DB
     $values = array();
     $entityBlock = array('contact_id' => $contactId);
     $values = CRM_Core_BAO_Location::getValues($entityBlock);
     //Now check values of address
     $this->assertAttributesEquals(CRM_Utils_Array::value('1', $params['address']), CRM_Utils_Array::value('1', $values['address']));
     //Now check values of email
     $this->assertAttributesEquals(CRM_Utils_Array::value('1', $params['email']), CRM_Utils_Array::value('1', $values['email']));
     //Now check values of phone
     $this->assertAttributesEquals(CRM_Utils_Array::value('1', $params['phone']), CRM_Utils_Array::value('1', $values['phone']));
     //Now check values of mobile
     $this->assertAttributesEquals(CRM_Utils_Array::value('2', $params['phone']), CRM_Utils_Array::value('2', $values['phone']));
     //Now check values of openid
     $this->assertAttributesEquals(CRM_Utils_Array::value('1', $params['openid']), CRM_Utils_Array::value('1', $values['openid']));
     //Now check values of im
     $this->assertAttributesEquals(CRM_Utils_Array::value('1', $params['im']), CRM_Utils_Array::value('1', $values['im']));
     //cleanup DB by deleting the contact
     Contact::delete($contactId);
 }
Exemplo n.º 28
0
 /**
  * Test case for deleteActivityAssignment() method.
  *
  * deleteActivityAssignment($activityId) method deletes activity assignment for given activity id.
  */
 public function testDeleteActivityAssignment()
 {
     $contactId = Contact::createIndividual();
     $params = array('first_name' => 'liz', 'last_name' => 'hurleey');
     $assigneeContactId = Contact::createIndividual($params);
     $params = array('source_contact_id' => $contactId, 'subject' => 'Scheduling Meeting', 'activity_type_id' => 2, 'assignee_contact_id' => array($assigneeContactId), 'activity_date_time' => date('Ymd'));
     CRM_Activity_BAO_Activity::create($params);
     $activityId = $this->assertDBNotNull('CRM_Activity_DAO_Activity', 'Scheduling Meeting', 'id', 'subject', 'Database check for created activity.');
     $activityAssignmentId = $this->assertDBNotNull('CRM_Activity_DAO_ActivityContact', $assigneeContactId, 'id', 'contact_id', 'Database check for created activity assignment.');
     CRM_Activity_BAO_Activity::deleteActivityContact($activityId, 1);
     $this->assertDBNull('CRM_Activity_DAO_ActivityContact', $assigneeContactId, 'id', 'contact_id', 'Database check for deleted activity assignment.');
     Contact::delete($contactId);
     Contact::delete($assigneeContactId);
 }
Exemplo n.º 29
0
 public function setUp()
 {
     parent::setUp();
     $this->_contactId = Contact::createIndividual();
     $this->_eventId = Event::create($this->_contactId);
 }
 /**
  * Add participant with contribution
  *
  * @return array
  */
 protected function createParticipantWithContribution()
 {
     // creating price set, price field
     $this->_contactId = Contact::createIndividual();
     $this->_eventId = Event::create($this->_contactId);
     $eventParams = array('id' => $this->_eventId, 'financial_type_id' => 4, 'is_monetary' => 1);
     $this->callAPISuccess('event', 'create', $eventParams);
     $priceFields = $this->createPriceSet('event', $this->_eventId);
     $participantParams = array('financial_type_id' => 4, 'event_id' => $this->_eventId, 'role_id' => 1, 'status_id' => 14, 'fee_currency' => 'USD', 'contact_id' => $this->_contactId);
     $participant = $this->callAPISuccess('Participant', 'create', $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;
     $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
     $paymentParticipant = array('participant_id' => $participant['id'], 'contribution_id' => $contribution['id']);
     $ids = array();
     $this->callAPISuccess('ParticipantPayment', 'create', $paymentParticipant);
     return array($lineItems, $contribution);
 }