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; function setUp() {
47 $this->ids
['contact'][0] = $this->individualCreate();
48 $this->params
= array(
50 'contact_id' => $this->ids
['contact'][0],
51 'installments' => '12',
52 'frequency_interval' => '1',
54 'contribution_status_id' => 1,
55 'start_date' => '2012-01-01 00:00:00',
57 'frequency_unit' => 'day',
62 foreach ($this->ids
as $entity => $entities) {
63 foreach ($entities as $id) {
64 civicrm_api($entity, 'delete', array('version' => $this->_apiversion
, 'id' => $id));
67 $tablesToTruncate = array(
68 'civicrm_financial_type',
69 'civicrm_contribution',
70 'civicrm_contribution_recur',
73 $this->quickCleanup($tablesToTruncate);
76 public function testCreateContributionRecur() {
77 $result = civicrm_api($this->_entity
, 'create', $this->params
);
78 $this->documentMe($this->params
, $result, __FUNCTION__
, __FILE__
);
79 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
80 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
81 $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__
);
82 $this->getAndCheck($this->params
, $result['id'], $this->_entity
);
85 public function testGetContributionRecur() {
86 $result = civicrm_api($this->_entity
, 'create', $this->params
);
88 'version' => $this->_apiversion
,
91 $result = civicrm_api($this->_entity
, 'get', $getParams);
92 $this->documentMe($getParams, $result, __FUNCTION__
, __FILE__
);
93 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
94 $this->assertEquals(1, $result['count'], 'In line ' . __LINE__
);
97 public function testDeleteContributionRecur() {
98 $result = civicrm_api($this->_entity
, 'create', $this->params
);
99 $deleteParams = array('version' => 3, 'id' => $result['id']);
100 $result = civicrm_api($this->_entity
, 'delete', $deleteParams);
101 $this->documentMe($deleteParams, $result, __FUNCTION__
, __FILE__
);
102 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
103 $checkDeleted = civicrm_api($this->_entity
, 'get', array(
106 $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__
);
109 public function testGetFieldsContributionRecur() {
110 $result = civicrm_api($this->_entity
, 'getfields', array('version' => 3, 'action' => 'create'));
111 $this->assertAPISuccess($result, 'In line ' . __LINE__
);
112 $this->assertEquals(12, $result['values']['start_date']['type']);