3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * Trait for working with Price Sets in tests
33 trait CRMTraits_Profile_ProfileTrait
{
36 * Add a profile to a contribution page.
38 * @param array $joinParams
39 * Must contain entity_id at minimum.
40 * @param array $ufGroupParams
42 protected function createJoinedProfile($joinParams, $ufGroupParams = []) {
43 $this->createProfile($ufGroupParams);
44 $joinParams = array_merge([
45 'uf_group_id' => 'our profile',
46 'entity_table' => 'civicrm_contribution_page',
49 if (empty($joinParams['module'])) {
50 $joinParams['module'] = $joinParams['entity_table'] === 'civicrm_event' ?
'CiviEvent' : 'CiviContribute';
52 if ($joinParams['module'] !== 'CiviContribute' && empty($joinParams['module_data'])) {
53 $params['module_data'] = [$joinParams['module'] => []];
55 $this->callAPISuccess('UFJoin', 'create', $joinParams);
61 * @param $ufGroupParams
63 protected function createProfile($ufGroupParams) {
64 $profile = $this->callAPISuccess('UFGroup', 'create', array_merge([
65 'group_type' => 'Contact',
66 'title' => 'Back end title',
67 'frontend_title' => 'Public title',
68 'name' => 'our profile',
71 $this->ids
['UFGroup'][$profile['values'][$profile['id']]['name']] = $profile['id'];
73 $this->callAPISuccess('UFField', 'create', [
74 'uf_group_id' => $profile['id'],
75 'field_name' => 'first_name',