*/
public function testCreateProportionalEntry($thousandSeparator) {
$this->setCurrencySeparators($thousandSeparator);
- list($contribution, $financialAccount) = $this->createContributionWithTax();
+ [$contribution, $financialAccount] = $this->createContributionWithTax();
$params = [
'total_amount' => 55,
'to_financial_account_id' => $financialAccount->financial_account_id,
* @param string $thousandSeparator
* punctuation used to refer to thousands.
*
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
* @dataProvider getThousandSeparators
*/
- public function testCreateProportionalEntryZeroAmount($thousandSeparator) {
+ public function testCreateProportionalEntryZeroAmount(string $thousandSeparator): void {
$this->setCurrencySeparators($thousandSeparator);
- list($contribution, $financialAccount) = $this->createContributionWithTax(['total_amount' => 0]);
+ [$contribution, $financialAccount] = $this->createContributionWithTax(['total_amount' => 0]);
$params = [
'total_amount' => 0,
'to_financial_account_id' => $financialAccount->financial_account_id,
* Test for function getLastFinancialItemIds().
*/
public function testgetLastFinancialItemIds() {
- list($contribution, $financialAccount) = $this->createContributionWithTax();
- list($ftIds, $taxItems) = CRM_Contribute_BAO_Contribution::getLastFinancialItemIds($contribution['id']);
+ [$contribution, $financialAccount] = $this->createContributionWithTax();
+ [$ftIds, $taxItems] = CRM_Contribute_BAO_Contribution::getLastFinancialItemIds($contribution['id']);
$this->assertEquals(count($ftIds), 1, 'Invalid count.');
$this->assertEquals(count($taxItems), 1, 'Invalid count.');
foreach ($taxItems as $value) {
* saved un-rounded).
*/
public function testCreateProportionalFinancialEntriesViaPaymentCreate() {
- list($contribution, $financialAccount) = $this->createContributionWithTax([], FALSE);
+ [$contribution, $financialAccount] = $this->createContributionWithTax([], FALSE);
$params = [
'total_amount' => 50,
'to_financial_account_id' => $financialAccount->financial_account_id,
* Test to check if amount is proportionally asigned for PI change.
*/
public function testProportionallyAssignedForPIChange() {
- list($contribution, $financialAccount) = $this->createContributionWithTax();
+ [$contribution, $financialAccount] = $this->createContributionWithTax();
$params = [
'id' => $contribution['id'],
'payment_instrument_id' => 3,
* Prepare for test.
*
* @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public function setUp(): void {
parent::setUp();
* @param int $version
*
* @dataProvider versionThreeAndFour
+ * @throws \CRM_Core_Exception
*/
- public function testCreateLineItemWithTax($version) {
+ public function testCreateLineItemWithTax($version): void {
$this->_apiversion = $version;
$this->enableSalesTaxOnFinancialType('Donation');
$this->params['financial_type_id'] = 'Donation';
/**
* Enable tax for the given financial type.
*
+ * @param string $type
+ *
+ * @throws \CRM_Core_Exception
* @todo move to a trait, share.
*
* @dataProvider versionThreeAndFour
*
- * @param string $type
*/
- public function enableSalesTaxOnFinancialType($type) {
+ public function enableSalesTaxOnFinancialType($type): void {
$this->enableTaxAndInvoicing();
$this->addTaxAccountToFinancialType(CRM_Core_PseudoConstant::getKey('CRM_Contribute_BAO_Contribution', 'financial_type_id', $type));
}
*
* @throws \CRM_Core_Exception
*/
- public function testCreateLineItem($version) {
+ public function testCreateLineItem(int $version): void {
$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 zero is valid for amount fields.
+ *
+ * https://github.com/civicrm/civicrm-core/pull/20342
+ *
+ * @param int $version
+ *
+ * @dataProvider versionThreeAndFour
+ *
+ * @throws \CRM_Core_Exception
+ */
+ public function testCreateLineItemZero(int $version): void {
+ $this->_apiversion = $version;
+ $this->callAPISuccess('LineItem', 'create', array_merge($this->params, ['unit_price' => 0, 'line_total' => 0]));
+ $this->callAPISuccess('LineItem', 'create', array_merge($this->params, ['unit_price' => 0.0, 'line_total' => 0.0]));
+ }
+
/**
* Test basic get line item.
*
*
* @dataProvider versionThreeAndFour
*/
- public function testGetBasicLineItem($version) {
+ public function testGetBasicLineItem($version): void {
$this->_apiversion = $version;
$getParams = [
'entity_table' => 'civicrm_contribution',
*
* @throws \CRM_Core_Exception
*/
- public function testDeleteLineItem($version) {
+ public function testDeleteLineItem($version): void {
$this->_apiversion = $version;
$getParams = [
'entity_table' => 'civicrm_contribution',
*
* @throws \CRM_Core_Exception
*/
- public function testGetFieldsLineItem() {
+ public function testGetFieldsLineItem(): void {
$result = $this->callAPISuccess($this->_entity, 'getfields', ['action' => 'create']);
$this->assertEquals(1, $result['values']['entity_id']['api.required']);
}