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

API allows creating multiple addresses same location type #10510

Merged
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
26 changes: 26 additions & 0 deletions tests/phpunit/api/v3/AddressTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,32 @@ public function testCreateAddressPrimaryHandlingChangeExisting() {
$this->callAPISuccess('address', 'delete', array('id' => $address1['id']));
}

/**
* Test Creating address of same type alreay ind the database
* This is legacy API v3 behaviour and not correct behaviour
* however we are too far down the path wiwth v3 to fix this
* @link https://chat.civicrm.org/civicrm/pl/zcq3jkg69jdt5g4aqze6bbe9pc
* @todo vis this in v4 api
*/
public function testCreateDuplicateLocationTypes() {
$address1 = $this->callAPISuccess('address', 'create', $this->_params);
$address2 = $this->callAPISuccess('address', 'create', array(
'location_type_id' => $this->_locationType->id,
'street_address' => '1600 Pensilvania Avenue',
'city' => 'Washington DC',
'is_primary' => 0,
'is_billing' => 0,
'contact_id' => $this->_contactID,
));
$check = $this->callAPISuccess('address', 'getcount', array(
'contact_id' => $this->_contactID,
'location_type_id' => $this->_locationType->id,
));
$this->assertEquals(2, $check);
$this->callAPISuccess('address', 'delete', array('id' => $address1['id']));
$this->callAPISuccess('address', 'delete', array('id' => $address2['id']));
}

public function testGetWithJoin() {
$cid = $this->individualCreate(array(
'api.Address.create' => array(
Expand Down