Skip to content

Commit

Permalink
Merge pull request #25201 from demeritcowboy/empty-checkbox
Browse files Browse the repository at this point in the history
[NFC] php8 - Unit test for empty checkbox array #23305
  • Loading branch information
seamuslee001 authored Dec 21, 2022
2 parents eba7ae4 + 7bc341d commit 04edd1c
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/phpunit/api/v3/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,49 @@ public function testCreateWithNULLCustomCRM12773(): void {
$this->customGroupDelete($ids['custom_group_id']);
}

/**
* Test create contact with custom checkbox with empty array
*/
public function testCreateWithEmptyCustomCheckbox(): void {
$this->callAPISuccess('OptionGroup', 'create', [
'name' => 'checkbox_opts',
'title' => 'Checkbox Options',
'data_type' => 'String',
'is_active' => 1,
]);
$this->callAPISuccess('OptionValue', 'create', [
'option_group_id' => 'checkbox_opts',
'name' => 'checkbox_option_one',
'label' => 'Checkbox Option One',
'is_active' => 1,
'value' => 1,
]);
$custom_group_id = $this->createCustomGroup([
'name' => 'checkbox_custom_group',
'title' => 'Checkbox Group',
'extends' => 'Contact',
]);
$custom_field_id = $this->callAPISuccess('CustomField', 'create', [
'name' => 'a_checkbox_field',
'label' => 'A Checkbox Field',
'custom_group_id' => $custom_group_id,
'option_group_id' => 'checkbox_opts',
'html_type' => 'CheckBox',
'data_type' => 'String',
'is_active' => 1,
])['id'];

$params = $this->_params;
$params['custom_' . $custom_field_id] = [];
$contact_id = $this->callAPISuccess('Contact', 'create', $params)['id'];

$result = $this->callAPISuccessGetSingle('Contact', ['id' => $contact_id, 'return' => ['custom_' . $custom_field_id]]);
$this->assertSame('', $result['custom_' . $custom_field_id]);

$this->customFieldDelete($custom_field_id);
$this->customGroupDelete($custom_group_id);
}

/**
* CRM-14232 test preferred language set to site default if not passed.
*
Expand Down

0 comments on commit 04edd1c

Please sign in to comment.