3b1c7a8a12be5bb35c412081302d1b2ff83c01f3
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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';
31 * Test class for Batch API - civicrm_batch_*
33 * @package CiviCRM_APIv3
35 class api_v3_BatchTest
extends CiviUnitTestCase
{
37 protected $_params = array();
38 protected $_entity = 'batch';
43 * Initialize configuration
45 function __construct() {
46 parent
::__construct();
50 * Sets up the fixture, for example, opens a network connection.
51 * This method is called before a test is executed.
55 protected function setUp() {
60 * Tears down the fixture, for example, closes a network connection.
61 * This method is called after a test is executed.
65 protected function tearDown() {
66 $tablesToTruncate = array('civicrm_batch');
67 $this->quickCleanup($tablesToTruncate);
71 * Create a sample batch
73 function batchCreate() {
74 $params = $this->_params
;
75 $params['name'] = $params['title'] = 'Batch_433397';
76 $params['status_id'] = 1;
77 $result = $this->callAPISuccess('batch', 'create', $params);
82 * Test civicrm_batch_get - success expected.
84 public function testGet() {
86 'id' => $this->batchCreate(),
88 $result = $this->callAPIAndDocument('batch', 'get', $params, __FUNCTION__
, __FILE__
);
89 $this->assertEquals($params['id'], $result['id'], 'In line ' . __LINE__
);
93 * Test civicrm_batch_create - success expected.
95 function testCreate() {
97 'name' => 'New_Batch_03',
98 'title' => 'New Batch 03',
99 'description' => 'This is description for New Batch 03',
105 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
106 $this->assertNotNull($result['id'], 'In line ' . __LINE__
);
107 $this->getAndCheck($params, $result['id'], $this->_entity
);
111 * Test civicrm_batch_create with id.
113 function testUpdate() {
115 'name' => 'New_Batch_04',
116 'title' => 'New Batch 04',
117 'description' => 'This is description for New Batch 04',
120 'id' => $this->batchCreate(),
123 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
124 $this->assertNotNull($result['id'], 'In line ' . __LINE__
);
125 $this->getAndCheck($params, $result['id'], $this->_entity
);
129 * Test civicrm_batch_delete using the old $params['batch_id'] syntax.
131 function testBatchDeleteOldSyntax() {
132 $batchID = $this->batchCreate();
134 'batch_id' => $batchID,
136 $result = $this->callAPISuccess('batch', 'delete', $params);
140 * Test civicrm_batch_delete using the new $params['id'] syntax
142 function testBatchDeleteCorrectSyntax() {
143 $batchID = $this->batchCreate();
147 $result = $this->callAPIAndDocument('batch', 'delete', $params, __FUNCTION__
, __FILE__
);