* @param array $ufGroupParams
*/
protected function createJoinedProfile($joinParams, $ufGroupParams = []) {
- $this->createProfile($ufGroupParams);
+ $profileID = $this->createProfile($ufGroupParams);
$joinParams = array_merge([
- 'uf_group_id' => 'our profile',
+ 'uf_group_id' => $profileID,
'entity_table' => 'civicrm_contribution_page',
'weight' => 1,
], $joinParams);
* Create a profile.
*
* @param $ufGroupParams
+ *
+ * @return int
*/
protected function createProfile($ufGroupParams) {
$profile = $this->callAPISuccess('UFGroup', 'create', array_merge([
'uf_group_id' => $profile['id'],
'field_name' => 'first_name',
]);
+ return $profile['id'];
+ }
+
+ /**
+ * Ensure we don't have a profile with the id or one to ensure that we are not casting an array to it.
+ */
+ protected function eliminateUFGroupOne() {
+ $profileID = $this->createProfile(['name' => 'dummy_for_removing']);
+ CRM_Core_DAO::executeQuery("UPDATE civicrm_uf_join SET uf_group_id = $profileID WHERE uf_group_id = 1");
+ CRM_Core_DAO::executeQuery("UPDATE civicrm_uf_field SET uf_group_id = $profileID WHERE uf_group_id = 1");
+ CRM_Core_DAO::executeQuery('UPDATE civicrm_uf_group SET id = 900 WHERE id = 1');
+ $this->ids['UFGroup']['dummy'] = $profileID;
+ }
+
+ /**
+ * Bring back UF group one.
+ */
+ protected function restoreUFGroupOne() {
+ if (!isset($this->ids['UFGroup']['dummy'])) {
+ return;
+ }
+ $profileID = $this->ids['UFGroup']['dummy'];
+ CRM_Core_DAO::executeQuery('UPDATE civicrm_uf_group SET id = 1 WHERE id = 900');
+ CRM_Core_DAO::executeQuery("UPDATE civicrm_uf_join SET uf_group_id = 1 WHERE uf_group_id = $profileID");
+ CRM_Core_DAO::executeQuery("UPDATE civicrm_uf_field SET uf_group_id = 1 WHERE uf_group_id = $profileID");
}
}
/**
* Clean up after each test.
+ *
+ * @throws \CRM_Core_Exception
*/
public function tearDown() {
$this->quickCleanUpFinancialEntities();
$this->quickCleanup(['civicrm_uf_match']);
$financialAccounts = $this->callAPISuccess('FinancialAccount', 'get', []);
foreach ($financialAccounts['values'] as $financialAccount) {
- if ($financialAccount['name'] == 'Test Tax financial account ' || $financialAccount['name'] == 'Test taxable financial Type') {
+ if ($financialAccount['name'] === 'Test Tax financial account ' || $financialAccount['name'] === 'Test taxable financial Type') {
$entityFinancialTypes = $this->callAPISuccess('EntityFinancialAccount', 'get', [
'financial_account_id' => $financialAccount['id'],
]);
$this->callAPISuccess('FinancialAccount', 'delete', ['id' => $financialAccount['id']]);
}
}
+ $this->restoreUFGroupOne();
}
/**
$this->_individualId = $this->createLoggedInUser();
$contributionID = $this->createPendingParticipantContribution();
$this->createJoinedProfile(['entity_id' => $this->_ids['event']['test'], 'entity_table' => 'civicrm_event']);
+ $this->createJoinedProfile(['entity_id' => $this->_ids['event']['test'], 'entity_table' => 'civicrm_event', 'weight' => 2], ['name' => 'post_1', 'title' => 'title_post_2', 'frontend_title' => 'public 2']);
+ $this->createJoinedProfile(['entity_id' => $this->_ids['event']['test'], 'entity_table' => 'civicrm_event', 'weight' => 3], ['name' => 'post_2', 'title' => 'title_post_3', 'frontend_title' => 'public 3']);
+ $this->eliminateUFGroupOne();
$this->callAPISuccess('contribution', 'completetransaction', [
'id' => $contributionID,
'contact_id' => $this->_individualId,
])['values'];
- $this->assertEquals(3, count($activities));
+ $this->assertCount(3, $activities);
$activityNames = array_count_values(CRM_Utils_Array::collect('activity_name', $activities));
// record two activities before and after completing payment for Event registration
$this->assertEquals(2, $activityNames['Event Registration']);
'This letter is a confirmation that your registration has been received and your status has been updated to Registered.',
'First Name: Logged In',
'Public title',
- ], ['Back end title']);
+ 'public 2',
+ 'public 3',
+ ], ['Back end title', 'title_post_2', 'title_post_3']);
$mut->stop();
}