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
38 class api_v3_ContributionPageTest
extends CiviUnitTestCase
{
39 protected $_apiversion = 3;
40 protected $testAmount = 34567;
43 protected $contactIds = array();
44 protected $_entity = 'contribution_page';
45 protected $contribution_result = null;
46 public $_eNoticeCompliant = TRUE;
47 public $DBResetRequired = TRUE;
48 public function setUp() {
50 $this->contactIds
[] = $this->individualCreate();
51 $this->params
= array(
52 'title' => "Test Contribution Page",
53 'financial_type_id' => 1,
55 'goal_amount' => $this->testAmount
,
60 foreach ($this->contactIds
as $id) {
61 $this->callAPISuccess('contact', 'delete', array('id' => $id));
62 }if(!empty($this->id
)){
63 $this->callAPISuccess('contribution_page', 'delete', array('id' => $this->id
));
67 public function testCreateContributionPage() {
68 $result = $this->callAPIAndDocument($this->_entity
, 'create', $this->params
, __FUNCTION__
, __FILE__
);
69 $this->assertEquals(1, $result['count']);
70 $this->assertNotNull($result['values'][$result['id']]['id']);
71 $this->getAndCheck($this->params
, $result['id'], $this->_entity
);
74 public function testGetBasicContributionPage() {
75 $createResult = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
76 $this->id
= $createResult['id'];
79 'financial_type_id' => 1,
81 $getResult = $this->callAPIAndDocument($this->_entity
, 'get', $getParams, __FUNCTION__
, __FILE__
);
82 $this->assertEquals(1, $getResult['count']);
85 public function testGetContributionPageByAmount() {
86 $createResult = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
87 $this->id
= $createResult['id'];
89 'amount' => ''. $this->testAmount
, // 3456
91 'financial_type_id' => 1,
93 $getResult = $this->callAPIAndDocument($this->_entity
, 'get', $getParams, __FUNCTION__
, __FILE__
);
94 $this->assertEquals(1, $getResult['count']);
97 public function testDeleteContributionPage() {
98 $createResult = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
99 $deleteParams = array('id' => $createResult['id']);
100 $deleteResult = $this->callAPIAndDocument($this->_entity
, 'delete', $deleteParams, __FUNCTION__
, __FILE__
);
101 $checkDeleted = $this->callAPISuccess($this->_entity
, 'get', array());
102 $this->assertEquals(0, $checkDeleted['count']);
105 public function testGetFieldsContributionPage() {
106 $result = $this->callAPISuccess($this->_entity
, 'getfields', array('action' => 'create'));
107 $this->assertEquals(12, $result['values']['start_date']['type']);
110 public static function setUpBeforeClass() {
111 // put stuff here that should happen before all tests in this unit
114 public static function tearDownAfterClass(){
115 $tablesToTruncate = array(
117 'civicrm_financial_type',
118 'civicrm_contribution',
119 'civicrm_contribution_page',
121 $unitTest = new CiviUnitTestCase();
122 $unitTest->quickCleanup($tablesToTruncate);