From bc72de3103e7828fb69235a7127667a748385d0c Mon Sep 17 00:00:00 2001 From: Belle Aerni Date: Fri, 19 Jan 2024 13:11:18 -0800 Subject: [PATCH] Improve clarity when marking unpaid invoices without a set gateway (#2088) * Improve clarity when marking unpaid invoices without a set gateway * Remove the quotes * Update AdminTest.php --- src/modules/Invoice/Api/Admin.php | 8 ++++++++ tests-legacy/modules/Invoice/Api/AdminTest.php | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/Invoice/Api/Admin.php b/src/modules/Invoice/Api/Admin.php index 4e1fa0749..6140b8762 100644 --- a/src/modules/Invoice/Api/Admin.php +++ b/src/modules/Invoice/Api/Admin.php @@ -1,4 +1,5 @@ _getInvoice($data); $gateway_id = ['id' => $invoice->gateway_id]; + + if (!$gateway_id['id']) { + throw new InformationException('You must set the payment gateway in the invoice manage tab before marking it as paid.'); + } + $payGateway = $this->gateway_get($gateway_id); $charge = false; diff --git a/tests-legacy/modules/Invoice/Api/AdminTest.php b/tests-legacy/modules/Invoice/Api/AdminTest.php index ebd2e5150..2db7e9008 100644 --- a/tests-legacy/modules/Invoice/Api/AdminTest.php +++ b/tests-legacy/modules/Invoice/Api/AdminTest.php @@ -91,9 +91,11 @@ class AdminTest extends \BBTestCase $validatorMock->expects($this->atLeastOnce()) ->method('checkRequiredParamsForArray'); - $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $model = new \Model_Invoice(); $model->loadBean(new \DummyBean()); + $model->gateway_id = '1'; + + $dbMock = $this->getMockBuilder('\Box_Database')->getMock(); $dbMock->expects($this->atLeastOnce()) ->method('getExistingModelById') ->willReturn($model);