3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | Use of this source code is governed by the AGPL license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Class CRM_Contribute_Form_Task_StatusTest
15 class CRM_Contribute_Form_Task_StatusTest
extends CiviUnitTestCase
{
17 protected $_individualId;
20 * Clean up after each test.
22 public function tearDown() {
23 $this->quickCleanUpFinancialEntities();
24 CRM_Utils_Hook
::singleton()->reset();
28 * Test update pending contribution
30 public function testUpdatePendingContribution() {
31 $this->_individualId
= $this->individualCreate();
32 $form = new CRM_Contribute_Form_Task_Status();
34 // create a pending contribution
35 $contributionParams = [
36 'contact_id' => $this->_individualId
,
37 'total_amount' => 100,
38 'financial_type_id' => 'Donation',
39 'contribution_status_id' => 2,
41 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
42 $contributionId = $contribution['id'];
43 $form->setContributionIds([$contributionId]);
45 $form->buildQuickForm();
48 "contribution_status_id" => 1,
49 "trxn_id_{$contributionId}" => NULL,
50 "check_number_{$contributionId}" => NULL,
51 "fee_amount_{$contributionId}" => 0,
52 "trxn_date_{$contributionId}" => date('m/d/Y'),
53 "payment_instrument_id_{$contributionId}" => 4,
56 CRM_Contribute_Form_Task_Status
::processForm($form, $params);
58 $contribution = $this->callAPISuccess('Contribution', 'get', ['id' => $contributionId]);
59 $updatedContribution = $contribution['values'][1];
61 $this->assertEquals('', $updatedContribution['contribution_source']);
62 $this->assertEquals(date("Y-m-d"), date("Y-m-d", strtotime($updatedContribution['receive_date'])));
63 $this->assertNotEquals("00:00:00", date("H:i:s", strtotime($updatedContribution['receive_date'])));
64 $this->assertEquals('Completed', $updatedContribution['contribution_status']);