*
* @return array
* Array of Order, if error an array with an error id and error message
+ * @throws \CiviCRM_API3_Exception
*/
-function civicrm_api3_order_get($params) {
+function civicrm_api3_order_get(array $params): array {
$contributions = [];
$params['api.line_item.get'] = ['qty' => ['<>' => 0]];
$isSequential = FALSE;
* @param array $params
* Array of parameters determined by getfields.
*/
-function _civicrm_api3_order_get_spec(&$params) {
+function _civicrm_api3_order_get_spec(array &$params) {
$params['id']['api.aliases'] = ['order_id'];
$params['id']['title'] = ts('Contribution / Order ID');
}
* @throws \CiviCRM_API3_Exception
* @throws API_Exception
*/
-function civicrm_api3_order_create($params) {
+function civicrm_api3_order_create(array $params): array {
civicrm_api3_verify_one_mandatory($params, NULL, ['line_items', 'total_amount']);
$entity = NULL;
$entityIds = [];
$entity . '_id' => $entityId,
];
// if entity is pledge then build pledge param
- if ($entity == 'pledge') {
+ if ($entity === 'pledge') {
$paymentParams += $entityParams;
}
- elseif ($entity == 'membership') {
+ elseif ($entity === 'membership') {
$contribution['values'][$contribution['id']]['membership_id'][] = $entityId;
$paymentParams['isSkipLineItem'] = TRUE;
}
*
* @param array $params
* Input parameters.
+ *
* @return array
* @throws API_Exception
* @throws CiviCRM_API3_Exception
*/
-function civicrm_api3_order_delete($params) {
+function civicrm_api3_order_delete(array $params): array {
$contribution = civicrm_api3('Contribution', 'get', [
'return' => ['is_test'],
'id' => $params['id'],
* Input parameters.
*
* @return array
+ * @throws \CiviCRM_API3_Exception
*/
-function civicrm_api3_order_cancel($params) {
+function civicrm_api3_order_cancel(array $params) {
$contributionStatuses = CRM_Contribute_PseudoConstant::contributionStatus(NULL, 'name');
$params['contribution_status_id'] = array_search('Cancelled', $contributionStatuses);
$result = civicrm_api3('Contribution', 'create', $params);
* @param array $params
* Array of parameters determined by getfields.
*/
-function _civicrm_api3_order_cancel_spec(&$params) {
+function _civicrm_api3_order_cancel_spec(array &$params) {
$params['contribution_id'] = [
'api.required' => 1,
'title' => 'Contribution ID',
* @param array $params
* Array of parameters determined by getfields.
*/
-function _civicrm_api3_order_create_spec(&$params) {
+function _civicrm_api3_order_create_spec(array &$params) {
$params['contact_id'] = [
'name' => 'contact_id',
'title' => 'Contact ID',
* @param array $params
* Array of parameters determined by getfields.
*/
-function _civicrm_api3_order_delete_spec(&$params) {
+function _civicrm_api3_order_delete_spec(array &$params) {
$params['contribution_id'] = [
'api.required' => TRUE,
'title' => 'Contribution ID',
*
* @param string $thousandSeparator
*
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
+ * @throws \Civi\Payment\Exception\PaymentProcessorException
* @dataProvider getThousandSeparators
*/
- public function testSubmit($thousandSeparator) {
+ public function testSubmit(string $thousandSeparator): void {
$this->setCurrencySeparators($thousandSeparator);
$form = new CRM_Contribute_Form_Contribution();
$form->testSubmit([
/**
* Test the submit function on the contribution page.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function testSubmitCreditCard() {
+ public function testSubmitCreditCard(): void {
$form = new CRM_Contribute_Form_Contribution();
$form->testSubmit([
'total_amount' => 50,
/**
* Test the submit function on the contribution page.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
- public function testSubmitCreditCardPayPal() {
+ public function testSubmitCreditCardPayPal(): void {
$mut = new CiviMailUtils($this, TRUE);
$mut->clearMessages();
$form = new CRM_Contribute_Form_Contribution();
]),
]);
- $this->assertEquals(1, $contribution["count"], "Contribution count should be one.");
- $this->assertTrue(!empty($contribution["values"][$contribution["id"]]["receipt_date"]), "Receipt date should not be blank.");
+ $this->assertEquals(1, $contribution['count'], 'Contribution count should be one.');
+ $this->assertNotTrue(empty($contribution['values'][$contribution['id']]['receipt_date']), 'Receipt date should not be blank.');
$contact = $this->callAPISuccessGetSingle('Contact', ['id' => $this->_individualId]);
$this->assertTrue(empty($contact['source']));
/**
* Test the submit function on the contribution page
+ *
+ * @throws \CRM_Core_Exception
*/
public function testSubmitCreditCardWithEmailReceipt() {
$mut = new CiviMailUtils($this, TRUE);
*
* @dataProvider getThousandSeparators
*/
- public function testSubmitUpdate($thousandSeparator) {
+ public function testSubmitUpdate(string $thousandSeparator): void {
$this->setCurrencySeparators($thousandSeparator);
$form = new CRM_Contribute_Form_Contribution();
/**
* Setup function.
+ *
+ * @throws \CRM_Core_Exception
*/
public function setUp(): void {
parent::setUp();
/**
* Test the LoadObjects function with recurring membership data.
*/
- public function testSendMailParticipantObjectsCheckLog() {
+ public function testSendMailParticipantObjectsCheckLog(): void {
$this->_setUpParticipantObjects();
$mut = new CiviMailUtils($this, TRUE);
$this->callAPISuccess('Contribution', 'sendconfirmation', [
/**
* Test the LoadObjects function with recurring membership data.
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \Exception
*/
- public function testsendMailParticipantObjectsNoMail() {
+ public function testsendMailParticipantObjectsNoMail(): void {
$this->_setUpParticipantObjects();
$event = new CRM_Event_BAO_Event();
$event->id = $this->_eventId;
/**
* Test the LoadObjects function with a pledge.
*/
- public function testSendMailPledge() {
+ public function testSendMailPledge(): void {
$this->_setUpPledgeObjects();
$contribution = new CRM_Contribute_BAO_Contribution();
$contribution->id = $this->_contributionId;
$this->assertStringContainsString('Contribution Information', $msg['html']);
}
- public function testThatCancellingEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities() {
+ /**
+ * @throws \API_Exception
+ * @throws \CRM_Core_Exception
+ * @throws \Civi\API\Exception\UnauthorizedException
+ * @throws \CiviCRM_API3_Exception
+ */
+ public function testThatCancellingEventPaymentWillCancelAllAdditionalPendingParticipantsAndCreateCancellationActivities(): void {
$this->_setUpParticipantObjects('Pending from incomplete transaction');
$additionalParticipantId = $this->participantCreate([
'event_id' => $this->_eventId,
'contribution_status_id:name' => 'Cancelled',
])->addWhere('id', '=', $this->_contributionId)->execute();
- $cancelledParticipantsCount = civicrm_api3('Participant', 'get', [
+ $cancelledParticipantsCount = $this->callAPISuccess('Participant', 'get', [
'sequential' => 1,
'id' => ['IN' => [$this->_participantId, $additionalParticipantId]],
'status_id' => 'Cancelled',
/**
* Prepare for membership test.
*/
- public function _setUpMembershipObjects() {
+ public function _setUpMembershipObjects(): void {
try {
if (!$this->_membershipTypeID) {
$this->_membershipTypeID = $this->membershipTypeCreate();