Autoformat /tests directory with php short array syntax
[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 protected $_individualId;
34
35 /**
36 * Clean up after each test.
37 */
38 public function tearDown() {
39 $this->quickCleanUpFinancialEntities();
40 CRM_Utils_Hook::singleton()->reset();
41 }
42
43 /**
44 * Test update pending contribution
45 */
46 public function testUpdatePendingContribution() {
47 $this->_individualId = $this->individualCreate();
48 $form = new CRM_Contribute_Form_Task_Status();
49
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,
56 ];
57 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
58 $contributionId = $contribution['id'];
59 $form->setContributionIds([$contributionId]);
60
61 $form->buildQuickForm();
62
63 $params = [
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,
70 ];
71
72 CRM_Contribute_Form_Task_Status::processForm($form, $params);
73
74 $contribution = $this->callAPISuccess('Contribution', 'get', ['id' => $contributionId]);
75 $updatedContribution = $contribution['values'][1];
76
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']);
81 }
82
83 }