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 * Assume empty database with just civicrm_data.
35 protected $_individualId;
38 * Clean up after each test.
40 public function tearDown() {
41 $this->quickCleanUpFinancialEntities();
42 CRM_Utils_Hook
::singleton()->reset();
46 * Test update pending contribution
48 public function testUpdatePendingContribution() {
49 $this->_individualId
= $this->individualCreate();
50 $form = new CRM_Contribute_Form_Task_Status();
52 // create a pending contribution
53 $contributionParams = array(
54 'contact_id' => $this->_individualId
,
55 'total_amount' => 100,
56 'financial_type_id' => 'Donation',
57 'contribution_status_id' => 2,
59 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
60 $contributionId = $contribution['id'];
61 $form->setContributionIds(array($contributionId));
63 $form->buildQuickForm();
66 "contribution_status_id" => 1,
67 "trxn_id_{$contributionId}" => NULL,
68 "check_number_{$contributionId}" => NULL,
69 "fee_amount_{$contributionId}" => 0,
70 "trxn_date_{$contributionId}" => date('m/d/Y'),
71 "payment_instrument_id_{$contributionId}" => 4,
74 CRM_Contribute_Form_Task_Status
::processForm($form, $params);
76 $contribution = $this->callAPISuccess('Contribution', 'get', array('id' => $contributionId));
77 $updatedContribution = $contribution['values'][1];
79 $this->assertEquals('', $updatedContribution['contribution_source']);
80 $this->assertEquals(date("Y-m-d"), date("Y-m-d", strtotime($updatedContribution['receive_date'])));
81 $this->assertNotEquals("00:00:00", date("H:i:s", strtotime($updatedContribution['receive_date'])));
82 $this->assertEquals('Completed', $updatedContribution['contribution_status']);