From aa1904e113340c6e4388b70a72f8efc10b6a1dab Mon Sep 17 00:00:00 2001 From: eileenmcnaugton Date: Wed, 5 Aug 2015 23:18:07 +1200 Subject: [PATCH] CRM-16168 api chaining fix (plus some test tidy up) --- api/api.php | 4 ++++ tests/phpunit/api/v3/EventTest.php | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/api/api.php b/api/api.php index 4f53c542fc..8b55d97347 100644 --- a/api/api.php +++ b/api/api.php @@ -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; + } } } } diff --git a/tests/phpunit/api/v3/EventTest.php b/tests/phpunit/api/v3/EventTest.php index 891010ef67..d7e9d7d40b 100644 --- a/tests/phpunit/api/v3/EventTest.php +++ b/tests/phpunit/api/v3/EventTest.php @@ -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'])); } -- 2.25.1