Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(NFC) Add unit test of creating notes from the contact.create API #13471

Merged
merged 1 commit into from
Jan 16, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions tests/phpunit/api/v3/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3902,4 +3902,31 @@ public function testSmartGroupsForRelatedContacts() {
$this->assertTrue($g3Contacts['count'] == 1);
}

/**
* Test creating a note from the contact.create API call when only passing the note as a string.
*/
public function testCreateNoteinCreate() {
$loggedInContactID = $this->createLoggedInUser();
$this->_params['note'] = "Test note created by API Call as a String";
$contact = $this->callAPISuccess('Contact', 'create', $this->_params);
$note = $this->callAPISuccess('Note', 'get', ['contact_id' => $loggedInContactID]);
$this->assertEquals($note['values'][$note['id']]['note'], "Test note created by API Call as a String");
$note = $this->callAPISuccess('Note', 'get', ['entity_id' => $contact['id']]);
$this->assertEquals($note['values'][$note['id']]['note'], "Test note created by API Call as a String");
$this->callAPISuccess('Contact', 'delete', ['id' => $contact['id'], 'skip_undelete' => TRUE]);
}

/**
* Test Creating a note from the contact.create api call when passing the note params as an array.
*/
public function testCreateNoteinCreateArrayFormat() {
$contact1 = $this->callAPISuccess('Contact', 'create', array('first_name' => 'Alan', 'last_name' => 'MouseMouse', 'contact_type' => 'Individual'));
$this->_params['note'] = [['note' => "Test note created by API Call as array", 'contact_id' => $contact1['id']]];
$contact2 = $this->callAPISuccess('Contact', 'create', $this->_params);
$note = $this->callAPISuccess('Note', 'get', ['contact_id' => $contact1['id']]);
$this->assertEquals($note['values'][$note['id']]['note'], "Test note created by API Call as array");
$note = $this->callAPISuccess('Note', 'get', ['entity_id' => $contact2['id']]);
$this->assertEquals($note['values'][$note['id']]['note'], "Test note created by API Call as array");
}

}