3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Class CRM_Contribute_Form_Task_StatusTest
31 class CRM_Contribute_Form_Task_StatusTest
extends CiviUnitTestCase
{
33 protected $_individualId;
36 * Clean up after each test.
38 public function tearDown() {
39 $this->quickCleanUpFinancialEntities();
40 CRM_Utils_Hook
::singleton()->reset();
44 * Test update pending contribution
46 public function testUpdatePendingContribution() {
47 $this->_individualId
= $this->individualCreate();
48 $form = new CRM_Contribute_Form_Task_Status();
50 // create a pending contribution
51 $contributionParams = [
52 'contact_id' => $this->_individualId
,
53 'total_amount' => 100,
54 'financial_type_id' => 'Donation',
55 'contribution_status_id' => 2,
57 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
58 $contributionId = $contribution['id'];
59 $form->setContributionIds([$contributionId]);
61 $form->buildQuickForm();
64 "contribution_status_id" => 1,
65 "trxn_id_{$contributionId}" => NULL,
66 "check_number_{$contributionId}" => NULL,
67 "fee_amount_{$contributionId}" => 0,
68 "trxn_date_{$contributionId}" => date('m/d/Y'),
69 "payment_instrument_id_{$contributionId}" => 4,
72 CRM_Contribute_Form_Task_Status
::processForm($form, $params);
74 $contribution = $this->callAPISuccess('Contribution', 'get', ['id' => $contributionId]);
75 $updatedContribution = $contribution['values'][1];
77 $this->assertEquals('', $updatedContribution['contribution_source']);
78 $this->assertEquals(date("Y-m-d"), date("Y-m-d", strtotime($updatedContribution['receive_date'])));
79 $this->assertNotEquals("00:00:00", date("H:i:s", strtotime($updatedContribution['receive_date'])));
80 $this->assertEquals('Completed', $updatedContribution['contribution_status']);