Commit | Line | Data |
---|---|---|
bbf58b03 EM |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
bbf58b03 | 5 | +--------------------------------------------------------------------+ |
39de6fd5 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
bbf58b03 EM |
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 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
bbf58b03 EM |
27 | |
28 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
92915c55 | 29 | |
7fe37828 EM |
30 | /** |
31 | * Class CRM_Contribute_BAO_ContributionRecurTest | |
32 | */ | |
bbf58b03 EM |
33 | class CRM_Contribute_BAO_ContributionRecurTest extends CiviUnitTestCase { |
34 | protected $_params = array(); | |
35 | ||
00be9182 | 36 | public function setUp() { |
bbf58b03 EM |
37 | parent::setUp(); |
38 | $this->_ids['payment_processor'] = $this->paymentProcessorCreate(); | |
39 | $this->_params = array( | |
40 | 'contact_id' => $this->individualCreate(), | |
41 | 'amount' => 3.00, | |
42 | 'frequency_unit' => 'week', | |
43 | 'frequency_interval' => 1, | |
44 | 'installments' => 2, | |
45 | 'start_date' => 'yesterday', | |
46 | 'create_date' => 'yesterday', | |
47 | 'modified_date' => 'yesterday', | |
48 | 'cancel_date' => NULL, | |
49 | 'end_date' => '+ 2 weeks', | |
50 | 'processor_id' => '643411460836', | |
51 | 'trxn_id' => 'e0d0808e26f3e661c6c18eb7c039d363', | |
52 | 'invoice_id' => 'e0d0808e26f3e661c6c18eb7c039d363', | |
53 | 'contribution_status_id' => 1, | |
54 | 'is_test' => 0, | |
55 | 'cycle_day' => 1, | |
56 | 'next_sched_contribution_date' => '+ 1 week', | |
57 | 'failure_count' => 0, | |
58 | 'failure_retry_date' => NULL, | |
59 | 'auto_renew' => 0, | |
60 | 'currency' => 'USD', | |
61 | 'payment_processor_id' => $this->_ids['payment_processor'], | |
62 | 'is_email_receipt' => 1, | |
63 | 'financial_type_id' => 1, | |
64 | 'payment_instrument_id' => 1, | |
65 | 'campaign_id' => NULL, | |
66 | ); | |
67 | } | |
68 | ||
00be9182 | 69 | public function teardown() { |
bbf58b03 EM |
70 | $this->quickCleanup(array('civicrm_contribution_recur', 'civicrm_payment_processor')); |
71 | } | |
72 | ||
73 | /** | |
fe482240 EM |
74 | * Test that an object can be retrieved & saved (per CRM-14986). |
75 | * | |
76 | * This has been causing a DB error so we are checking for absence of error | |
bbf58b03 | 77 | */ |
00be9182 | 78 | public function testFindSave() { |
bbf58b03 EM |
79 | $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', $this->_params); |
80 | $dao = new CRM_Contribute_BAO_ContributionRecur(); | |
81 | $dao->id = $contributionRecur['id']; | |
82 | $dao->find(TRUE); | |
83 | $dao->is_email_receipt = 0; | |
84 | $dao->save(); | |
85 | } | |
86 | ||
87 | /** | |
fe482240 EM |
88 | * Test cancellation works per CRM-14986. |
89 | * | |
90 | * We are checking for absence of error. | |
bbf58b03 | 91 | */ |
00be9182 | 92 | public function testCancelRecur() { |
bbf58b03 EM |
93 | $contributionRecur = $this->callAPISuccess('contribution_recur', 'create', $this->_params); |
94 | CRM_Contribute_BAO_ContributionRecur::cancelRecurContribution($contributionRecur['id'], CRM_Core_DAO::$_nullObject); | |
95 | } | |
96 | ||
97 | } |