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