function create($contributionPageId) { $profileParams = array('group_type' => 'Individual,Contact', 'title' => 'Test Supprorter Profile', 'help_pre' => 'Profle to PCP Contribution', 'is_active' => 1, 'is_cms_user' => 2); $ufGroup = civicrm_uf_group_create($profileParams); $profileId = $ufGroup['id']; $fieldsParams = array(array('field_name' => 'first_name', 'field_type' => 'Individual', 'visibility' => 'Public Pages and Listings', 'weight' => 1, 'label' => 'First Name', 'is_required' => 1, 'is_active' => 1), array('field_name' => 'last_name', 'field_type' => 'Individual', 'visibility' => 'Public Pages and Listings', 'weight' => 2, 'label' => 'Last Name', 'is_required' => 1, 'is_active' => 1), array('field_name' => 'email', 'field_type' => 'Contact', 'visibility' => 'Public Pages and Listings', 'weight' => 3, 'label' => 'Email', 'is_required' => 1, 'is_active' => 1)); foreach ($fieldsParams as $value) { $ufField = civicrm_uf_field_create($profileId, $value); } $joinParams = array('module' => 'Profile', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => 1, 'weight' => 1, 'uf_group_id' => $profileId, 'is_active' => 1); require_once 'api/v2/UFJoin.php'; $ufJoin = civicrm_uf_join_add($joinParams); $params = array('entity_table' => 'civicrm_contribution_page', 'entity_id' => $contributionPageId, 'supporter_profile_id' => $profileId, 'is_approval_needed' => 0, 'is_tellfriend_enabled' => 0, 'tellfriend_limit' => 0, 'link_text' => 'Create your own Personal Campaign Page!', 'is_active' => 1, 'notify_email' => '*****@*****.**'); require_once 'CRM/Contribute/BAO/PCP.php'; $blockPCP = CRM_Contribute_BAO_PCP::add($params); return array('blockId' => $blockPCP->id, 'profileId' => $profileId); }
function testGroupCreateWithWrongParams() { $result = civicrm_uf_group_create('a string'); $this->assertEquals($result['is_error'], 1); $result = civicrm_uf_group_create(array('name' => 'A title-less group')); $this->assertEquals($result['is_error'], 1); }