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