(NFC) (dev/core#878) Simplify copyright header (tests/*)
[civicrm-core.git] / tests / phpunit / CRM / Contribute / Form / Task / StatusTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Class CRM_Contribute_Form_Task_StatusTest
14 */
15 class CRM_Contribute_Form_Task_StatusTest extends CiviUnitTestCase {
16
17 protected $_individualId;
18
19 /**
20 * Clean up after each test.
21 */
22 public function tearDown() {
23 $this->quickCleanUpFinancialEntities();
24 CRM_Utils_Hook::singleton()->reset();
25 }
26
27 /**
28 * Test update pending contribution
29 */
30 public function testUpdatePendingContribution() {
31 $this->_individualId = $this->individualCreate();
32 $form = new CRM_Contribute_Form_Task_Status();
33
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,
40 ];
41 $contribution = $this->callAPISuccess('Contribution', 'create', $contributionParams);
42 $contributionId = $contribution['id'];
43 $form->setContributionIds([$contributionId]);
44
45 $form->buildQuickForm();
46
47 $params = [
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,
54 ];
55
56 CRM_Contribute_Form_Task_Status::processForm($form, $params);
57
58 $contribution = $this->callAPISuccess('Contribution', 'get', ['id' => $contributionId]);
59 $updatedContribution = $contribution['values'][1];
60
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']);
65 }
66
67 }