Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev/core#1980 Add v4 api LineItem entity #18388

Merged
merged 1 commit into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions Civi/Api4/LineItem.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC. All rights reserved. |
| |
| This work is published under the GNU AGPLv3 license with some |
| permitted exceptions and without any warranty. For full license |
| and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/

/**
*
* @package CRM
* @copyright CiviCRM LLC https://civicrm.org/licensing
*/

namespace Civi\Api4;

/**
* LineItem entity.
*
* @package Civi\Api4
*/
class LineItem extends Generic\DAOEntity {

}
30 changes: 26 additions & 4 deletions tests/phpunit/api/v3/LineItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ public function setUp() {

/**
* Test tax is calculated correctly on the line item.
*
* @param int $version
*
* @dataProvider versionThreeAndFour
*/
public function testCreateLineItemWithTax() {
public function testCreateLineItemWithTax($version) {
$this->_apiversion = $version;
$this->enableSalesTaxOnFinancialType('Donation');
$this->params['financial_type_id'] = 'Donation';
$result = $this->callAPISuccess('LineItem', 'create', $this->params);
Expand All @@ -67,6 +72,8 @@ public function testCreateLineItemWithTax() {
*
* @todo move to a trait, share.
*
* @dataProvider versionThreeAndFour
*
* @param string $type
*/
public function enableSalesTaxOnFinancialType($type) {
Expand All @@ -77,18 +84,28 @@ public function enableSalesTaxOnFinancialType($type) {
/**
* 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);
}

/**
* 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',
];
Expand All @@ -99,9 +116,14 @@ public function testGetBasicLineItem() {
/**
* 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',
];
Expand Down