CRM-16168 api chaining fix (plus some test tidy up)
authoreileenmcnaugton <eileen@fuzion.co.nz>
Wed, 5 Aug 2015 11:18:07 +0000 (23:18 +1200)
committereileenmcnaugton <eileen@fuzion.co.nz>
Wed, 5 Aug 2015 11:18:07 +0000 (23:18 +1200)
api/api.php
tests/phpunit/api/v3/EventTest.php

index 4f53c542fc0324b54e6361ee65a70ba28f963cc5..8b55d97347e26335c6a7e5a35d93db3ac4556a8d 100644 (file)
@@ -158,6 +158,10 @@ function _civicrm_api_replace_variables(&$params, &$parentResult, $separator = '
           $count = count($stringParts);
         }
       }
+      // CRM-16168 If we have failed to swap it out we should unset it rather than leave the placeholder.
+      if (substr($params[$field], 0, 6) == '$value') {
+        $params[$field] = NULL;
+      }
     }
   }
 }
index 891010ef67507fb52be813e0832670ccf650ea91..d7e9d7d40b0f07709fdd44e4ebeb66170958d9a3 100644 (file)
@@ -327,15 +327,14 @@ class api_v3_EventTest extends CiviUnitTestCase {
    */
   public function testChainingGetNonExistingLocBlock() {
     $params = $this->_params[0];
-    $result = $this->callAPIAndDocument($this->_entity, 'create', $params, __FUNCTION__, __FILE__);
+    $result = $this->callAPISuccess($this->_entity, 'create', $params);
 
     $check = $this->callAPISuccess($this->_entity, 'get', array(
       'id' => $result['id'],
       // this chaining request should not break things:
       'api.LocBlock.get' => array('id' => '$value.loc_block_id'),
       ));
-    $this->assertEquals(0, $check['is_error'], ' in line ' . __LINE__);
-    $this->assertEquals($result['id'], $check['id'], ' in line ' . __LINE__);
+    $this->assertEquals($result['id'], $check['id']);
 
     $this->callAPISuccess($this->_entity, 'Delete', array('id' => $result['id']));
   }