dev/core#2044 Make contact_id optional on v4 api for Address, phone, email
authoreileen <emcnaughton@wikimedia.org>
Wed, 23 Sep 2020 23:23:20 +0000 (11:23 +1200)
committereileen <emcnaughton@wikimedia.org>
Wed, 23 Sep 2020 23:23:20 +0000 (11:23 +1200)
It's optional in the schema for events etc

Civi/Api4/Service/Spec/Provider/AddressCreationSpecProvider.php
Civi/Api4/Service/Spec/Provider/EmailCreationSpecProvider.php
Civi/Api4/Service/Spec/Provider/PhoneCreationSpecProvider.php
tests/phpunit/api/v3/AddressTest.php

index 1b29d79350bca3a78589099c8727d16cda200b4c..b929cb9da5161d88988d6b541268ff79ea14f90a 100644 (file)
@@ -27,7 +27,6 @@ class AddressCreationSpecProvider implements Generic\SpecProviderInterface {
    * @param \Civi\Api4\Service\Spec\RequestSpec $spec
    */
   public function modifySpec(RequestSpec $spec) {
-    $spec->getFieldByName('contact_id')->setRequired(TRUE);
     $spec->getFieldByName('location_type_id')->setRequired(TRUE);
   }
 
index a7b0dd8a7ef80af502f0f2c7888f68c354ec2012..8bbb299b450871f03245cb88902e0bc8f9c785c2 100644 (file)
@@ -27,7 +27,6 @@ class EmailCreationSpecProvider implements Generic\SpecProviderInterface {
    * @inheritDoc
    */
   public function modifySpec(RequestSpec $spec) {
-    $spec->getFieldByName('contact_id')->setRequired(TRUE);
     $spec->getFieldByName('email')->setRequired(TRUE);
     $spec->getFieldByName('on_hold')->setRequired(FALSE);
     $spec->getFieldByName('is_bulkmail')->setRequired(FALSE);
index 27aef02c9afc39a36d233c2fd4669e4a6ca0110b..4faecb1c5539d23b0e39a4775a7a5d7ccae37568 100644 (file)
@@ -27,7 +27,6 @@ class PhoneCreationSpecProvider implements Generic\SpecProviderInterface {
    * @inheritDoc
    */
   public function modifySpec(RequestSpec $spec) {
-    $spec->getFieldByName('contact_id')->setRequired(TRUE);
     $spec->getFieldByName('phone')->setRequired(TRUE);
   }
 
index 2a12ef95f5c4f029e7706acfcebd4880135af4f9..400dacabb48afd3167fe2c7875b825336678081c 100644 (file)
@@ -57,11 +57,13 @@ class api_v3_AddressTest extends CiviUnitTestCase {
 
   /**
    * @param int $version
+   *
    * @dataProvider versionThreeAndFour
+   * @throws \CRM_Core_Exception
    */
   public function testCreateAddress($version) {
     $this->_apiversion = $version;
-    $result = $this->callAPIAndDocument('address', 'create', $this->_params, __FUNCTION__, __FILE__);
+    $result = $this->callAPIAndDocument('Address', 'create', $this->_params, __FUNCTION__, __FILE__);
     $this->assertEquals(1, $result['count']);
     $this->assertNotNull($result['values'][$result['id']]['id']);
     $this->getAndCheck($this->_params, $result['id'], 'address');