From ba5e66f74649dcff0884aee170a7ce41c76a2acc Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 7 Sep 2020 08:25:44 +1200 Subject: [PATCH] Add v4 api LineItem entity --- Civi/Api4/LineItem.php | 28 +++++++++++++++++++++++++ tests/phpunit/api/v3/LineItemTest.php | 30 +++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 Civi/Api4/LineItem.php diff --git a/Civi/Api4/LineItem.php b/Civi/Api4/LineItem.php new file mode 100644 index 0000000000..c630346a4b --- /dev/null +++ b/Civi/Api4/LineItem.php @@ -0,0 +1,28 @@ +_apiversion = $version; $this->enableSalesTaxOnFinancialType('Donation'); $this->params['financial_type_id'] = 'Donation'; $result = $this->callAPISuccess('LineItem', 'create', $this->params); @@ -67,6 +72,8 @@ class api_v3_LineItemTest extends CiviUnitTestCase { * * @todo move to a trait, share. * + * @dataProvider versionThreeAndFour + * * @param string $type */ public function enableSalesTaxOnFinancialType($type) { @@ -77,9 +84,14 @@ class api_v3_LineItemTest extends CiviUnitTestCase { /** * Test basic create line item. * + * @param int $version + * + * @dataProvider versionThreeAndFour + * * @throws \CRM_Core_Exception */ - public function testCreateLineItem() { + public function testCreateLineItem($version) { + $this->_apiversion = $version; $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__)['values']; $this->assertCount(1, $result); $this->getAndCheck($this->params, key($result), $this->_entity); @@ -87,8 +99,13 @@ class api_v3_LineItemTest extends CiviUnitTestCase { /** * Test basic get line item. + * + * @param int $version + * + * @dataProvider versionThreeAndFour */ - public function testGetBasicLineItem() { + public function testGetBasicLineItem($version) { + $this->_apiversion = $version; $getParams = [ 'entity_table' => 'civicrm_contribution', ]; @@ -99,9 +116,14 @@ class api_v3_LineItemTest extends CiviUnitTestCase { /** * Test delete line item. * + * @param int $version + * + * @dataProvider versionThreeAndFour + * * @throws \CRM_Core_Exception */ - public function testDeleteLineItem() { + public function testDeleteLineItem($version) { + $this->_apiversion = $version; $getParams = [ 'entity_table' => 'civicrm_contribution', ]; -- 2.25.1