Merge pull request #13657 from MegaphoneJon/deprecateBasicContactFields
[civicrm-core.git] / tests / phpunit / CRM / Contribute / Form / Task / StatusTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28 /**
29 * Class CRM_Contribute_Form_Task_StatusTest
30 */
31 class CRM_Contribute_Form_Task_StatusTest extends CiviUnitTestCase {
32 /**
33 * Assume empty database with just civicrm_data.
34 */
35 protected $_individualId;
36
37 /**
38 * Clean up after each test.
39 */
40 public function tearDown() {
41 $this->quickCleanUpFinancialEntities();
42 CRM_Utils_Hook::singleton()->reset();
43 }
44
45 /**
46 * Test update pending contribution
47 */
48 public function testUpdatePendingContribution() {
49 $this->_individualId = $this->individualCreate();
50 $form = new CRM_Contribute_Form_Task_Status();
51
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,
58 );
59 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
60 $contributionId = $contribution['id'];
61 $form->setContributionIds(array($contributionId));
62
63 $form->buildQuickForm();
64
65 $params = array(
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,
72 );
73
74 CRM_Contribute_Form_Task_Status::processForm($form, $params);
75
76 $contribution = $this->callAPISuccess('Contribution', 'get', array('id' => $contributionId));
77 $updatedContribution = $contribution['values'][1];
78
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']);
83 }
84
85 }