API allows creating multiple addresses same location type
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 15 Jun 2017 03:32:00 +0000 (13:32 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 15 Jun 2017 03:32:00 +0000 (13:32 +1000)
tests/phpunit/api/v3/AddressTest.php

index 560a1b164c09eefa88fd709609fb5e9fecd93927..f999e29ec2dde516e0ed576f0aea2693406350d0 100644 (file)
@@ -348,6 +348,28 @@ class api_v3_AddressTest extends CiviUnitTestCase {
     $this->callAPISuccess('address', 'delete', array('id' => $address1['id']));
   }
 
+  /**
+   * Test Creating address of same type alreay ind the database
+   */
+  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(