Skip to content

Commit

Permalink
Cleanup profile test to not use discontinuted dbunit
Browse files Browse the repository at this point in the history
  • Loading branch information
eileen authored and eileenmcnaughton committed May 23, 2019
1 parent 265ce2a commit d5f00ca
Showing 1 changed file with 82 additions and 17 deletions.
99 changes: 82 additions & 17 deletions tests/phpunit/api/v3/ProfileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,8 @@ public function testContactActivityGetWrongActivityId() {
* @throws \Exception
*/
public function testContactActivityGetWrongActivityType() {
$sourceContactId = $this->householdCreate();

$activityParams = [
'source_contact_id' => $sourceContactId,
$activity = $this->callAPISuccess('activity', 'create', [
'source_contact_id' => $this->householdCreate(),
'activity_type_id' => '2',
'subject' => 'Test activity',
'activity_date_time' => '20110316',
Expand All @@ -276,9 +274,7 @@ public function testContactActivityGetWrongActivityType() {
'details' => 'a test activity',
'status_id' => '1',
'priority_id' => '1',
];

$activity = $this->callAPISuccess('activity', 'create', $activityParams)['values'];
]);

$activityValues = array_pop($activity);

Expand Down Expand Up @@ -873,15 +869,84 @@ public function _createIndividualContact($params = []) {
* @return array
*/
public function _createContactWithActivity() {
// @TODO: Create profile with custom fields
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
$this->createFlatXMLDataSet(
dirname(__FILE__) . '/dataset/uf_group_contact_activity_26.xml'
)
);
// hack: xml data set do not accept  (CRM_Core_DAO::VALUE_SEPARATOR)
CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', '26', 'group_type', 'Individual,Contact,Activity' . CRM_Core_DAO::VALUE_SEPARATOR . 'ActivityType:1');
$ufGroupID = $this->callAPISuccess('UFGroup', 'create', [
'group_type' => 'Individual,Contact,Activity',
'title' => 'Test Contact-Activity Profile',
'name' => 'test_contact_activity_profile',
])['id'];
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'first_name',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'First Name',
'field_type' => 'Individual',
]);
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'last_name',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'Last Name',
'field_type' => 'Individual',
]);
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'email',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'Email',
'field_type' => 'Contact',
]);
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'activity_subject',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'Activity Subject',
'is_searchable' => TRUE,
'field_type' => 'Activity',
]);
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'activity_details',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'Activity Details',
'is_searchable' => TRUE,
'field_type' => 'Activity',
]);
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'activity_duration',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'Activity Duration',
'is_searchable' => TRUE,
'field_type' => 'Activity',
]);
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'activity_date_time',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'Activity Date',
'is_searchable' => TRUE,
'field_type' => 'Activity',
]);
$this->callAPISuccess('UFField', 'create', [
'uf_group_id' => $ufGroupID,
'field_name' => 'activity_status_id',
'is_required' => TRUE,
'visibility' => 'Public Pages and Listings',
'label' => 'Activity Status',
'is_searchable' => TRUE,
'field_type' => 'Activity',
]);

// hack: xml data set did not accept  (CRM_Core_DAO::VALUE_SEPARATOR) - should be possible
// to unhack now we use the api.
CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $ufGroupID, 'group_type', 'Individual,Contact,Activity' . CRM_Core_DAO::VALUE_SEPARATOR . 'ActivityType:1');

$sourceContactId = $this->individualCreate();
$contactParams = [
Expand Down Expand Up @@ -928,7 +993,7 @@ public function _createContactWithActivity() {

// valid parameters for above profile
$profileParams = [
'profile_id' => 26,
'profile_id' => $ufGroupID,
'contact_id' => $contactId,
'activity_id' => $activityValues['id'],
];
Expand Down

0 comments on commit d5f00ca

Please sign in to comment.