From 8744e9ceac992182aeaab496aa8a1f5f9a7d6cd4 Mon Sep 17 00:00:00 2001 From: eileen Date: Sat, 5 Jan 2019 11:21:24 +1300 Subject: [PATCH] dev/core#643 Add test for bug with double chaining on getsingle --- api/v3/Contribution.php | 2 +- tests/phpunit/api/v3/ContributionTest.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/v3/Contribution.php b/api/v3/Contribution.php index a52600f6d8..a5b33bf16f 100644 --- a/api/v3/Contribution.php +++ b/api/v3/Contribution.php @@ -231,7 +231,7 @@ function civicrm_api3_contribution_delete($params) { return civicrm_api3_create_success(array($contributionID => 1)); } else { - return civicrm_api3_create_error('Could not delete contribution'); + throw new API_Exception('Could not delete contribution'); } } diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index dd4d790668..b6df822f75 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -1117,6 +1117,19 @@ class api_v3_ContributionTest extends CiviUnitTestCase { )); $this->assertEquals(1, $contribution['contribution_status_id']); $this->assertEquals('Check', $contribution['payment_instrument']); + $this->callAPISuccessGetCount('Contribution', ['id' => $contribution['id']], 0); + } + + /** + * Test that getsingle can be chained with delete. + */ + public function testDeleteChainedGetSingle() { + $contribution = $this->callAPISuccess('contribution', 'create', $this->_params); + $contribution = $this->callAPISuccess('contribution', 'getsingle', array( + 'id' => $contribution['id'], + 'api.contribution.delete' => 1, + )); + $this->callAPISuccessGetCount('Contribution', ['id' => $contribution['id']], 0); } /** -- 2.25.1