Skip to content

Commit

Permalink
WIP - adding (still non working) test.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcclelland committed Jun 8, 2022
1 parent c51c929 commit d40e6a0
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions tests/phpunit/CRM/Profile/Form/EditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,67 @@ public function testProfileUrl(): void {
$this->assertEquals('civicrm/Mr. Anthony Anderson II', CRM_Core_Session::singleton()->popUserContext());
}

/**
* Test that requiring tags on a profile works.
*
* @throws \API_Exception
*/
public function testProfileRequireTag(): void {
$ufGroupParams = [
'group_type' => 'Individual,Contact',
'name' => 'test_individual_contact_tag_profile',
'title' => 'Gimme a tag',
'api.uf_field.create' => [
[
'field_name' => 'first_name',
'is_required' => 1,
'visibility' => 'Public Pages and Listings',
'field_type' => 'Individual',
'label' => 'First Name',
],
[
'field_name' => 'last_name',
'is_required' => 1,
'visibility' => 'Public Pages and Listings',
'field_type' => 'Individual',
'label' => 'Last Name',
],
[
'field_name' => 'tag',
'is_required' => 1,
'visibility' => 'Public Pages and Listings',
'field_type' => 'Contact',
'label' => 'Tag',
],
]
];

$profile = $this->callAPISuccess('uf_group', 'create', $ufGroupParams);
$profileID = $profile['id'];

// Configure the profile to be used as a standalone profile for data entry.
UFJoin::create(FALSE)->setValues([
'module' => 'Profile',
'uf_group_id' => $profileID,
])->execute();

// Populate the form.
$formParams = [
'first_name' => 'Foo',
'last_name' => 'McGoo',
'gid' => $profileID,
'tag' => [],
];
$form = $this->getFormObject('CRM_Profile_Form_Edit', $formParams);
$form->set('gid', $profileID);
$form->preProcess();
$form->buildQuickForm();
$form->postProcess();

// $files = [];
// $validationResult = $form->formRule($formParams, $files, $form);
// $this->assertIsArray($validationResult);
// $this->assertTrue(array_key_exists('tag', $validationResult));

}
}

0 comments on commit d40e6a0

Please sign in to comment.