3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.3 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
28 require_once 'CiviTest/CiviUnitTestCase.php';
32 * Test APIv3 civicrm_contribute_recur* functions
34 * @package CiviCRM_APIv3
35 * @subpackage API_Contribution
39 class api_v3_ContributionRecurTest
extends CiviUnitTestCase
{
40 protected $_apiversion = 3;
42 protected $ids = array();
43 protected $_entity = 'contribution_recur';
44 public $_eNoticeCompliant = TRUE;
45 public $DBResetRequired = FALSE;
49 $this->ids
['contact'][0] = $this->individualCreate();
50 $this->params
= array(
52 'contact_id' => $this->ids
['contact'][0],
53 'installments' => '12',
54 'frequency_interval' => '1',
56 'contribution_status_id' => 1,
57 'start_date' => '2012-01-01 00:00:00',
59 'frequency_unit' => 'day',
64 foreach ($this->ids
as $entity => $entities) {
65 foreach ($entities as $id) {
66 civicrm_api($entity, 'delete', array('version' => $this->_apiversion
, 'id' => $id));
69 $tablesToTruncate = array(
70 'civicrm_financial_type',
71 'civicrm_contribution',
72 'civicrm_contribution_recur',
75 $this->quickCleanup($tablesToTruncate);
78 public function testCreateContributionRecur() {
79 $result = civicrm_api($this->_entity
, 'create', $this->params
);
80 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
81 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
82 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
83 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
84 $this->getAndCheck($this->params
, $result['id'], $this->_entity
);
87 public function testGetContributionRecur() {
88 $result = civicrm_api($this->_entity
, 'create', $this->params
);
90 'version' => $this->_apiversion
,
93 $result = civicrm_api($this->_entity
, 'get', $getParams);
94 $this->documentMe($getParams, $result, __FUNCTION__
, __FILE__
);
95 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
96 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
99 public function testDeleteContributionRecur() {
100 $result = civicrm_api($this->_entity
, 'create', $this->params
);
101 $deleteParams = array('version' => 3, 'id' => $result['id']);
102 $result = civicrm_api($this->_entity
, 'delete', $deleteParams);
103 $this->documentMe($deleteParams, $result, __FUNCTION__
, __FILE__
);
104 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
105 $checkDeleted = civicrm_api($this->_entity
, 'get', array(
108 $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__
);
111 public function testGetFieldsContributionRecur() {
112 $result = civicrm_api($this->_entity
, 'getfields', array('version' => 3, 'action' => 'create'));
113 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
114 $this->assertEquals(12, $result['values']['start_date']['type']);