Skip to content

Commit

Permalink
CRM-21466 - Fix (obscure) enotice when updating greeting for contact,…
Browse files Browse the repository at this point in the history
… add test
  • Loading branch information
eileenmcnaughton committed Dec 2, 2017
1 parent d540139 commit 0db8cd8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
1 change: 0 additions & 1 deletion api/v3/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ function _civicrm_api3_greeting_format_params($params) {

$nullValue = FALSE;
$filter = array(
'contact_type' => $params['contact_type'],
'greeting_type' => "{$key}{$greeting}",
);

Expand Down
19 changes: 19 additions & 0 deletions tests/phpunit/api/v3/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3582,4 +3582,23 @@ public function testCreateCommunicationStylePassed() {
$this->assertEquals($communicationStyle['value'], $result['communication_style_id']);
}

/**
* Test that creating a contact with various contact greetings works.
*/
public function testContactGreetingsCreate() {
$contact = $this->callAPISuccess('Contact', 'create', array('first_name' => 'Alan', 'last_name' => 'MouseMouse', 'contact_type' => 'Individual'));
$contact = $this->callAPISuccessGetSingle('Contact', array('id' => $contact['id'], 'return' => 'postal_greeting'));
$this->assertEquals('Dear Alan', $contact['postal_greeting_display']);

$contact = $this->callAPISuccess('Contact', 'create', array('id' => $contact['id'], 'postal_greeting_id' => 2));
$contact = $this->callAPISuccessGetSingle('Contact', array('id' => $contact['id'], 'return' => 'postal_greeting'));
$this->assertEquals('Dear Alan MouseMouse', $contact['postal_greeting_display']);

$contact = $this->callAPISuccess('Contact', 'create', array('organization_name' => 'Alan\'s Show', 'contact_type' => 'Organization'));
$contact = $this->callAPISuccessGetSingle('Contact', array('id' => $contact['id'], 'return' => 'postal_greeting, addressee, email_greeting'));
$this->assertEquals('', $contact['postal_greeting_display']);
$this->assertEquals('', $contact['email_greeting_display']);
$this->assertEquals('Alan\'s Show', $contact['addressee_display']);
}

}

0 comments on commit 0db8cd8

Please sign in to comment.