3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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 +--------------------------------------------------------------------+
29 * Test class for Batch API - civicrm_batch_*
31 * @package CiviCRM_APIv3
34 class api_v3_BatchTest
extends CiviUnitTestCase
{
36 protected $_params = array();
37 protected $_entity = 'batch';
40 * Sets up the fixture, for example, opens a network connection.
42 * This method is called before a test is executed.
44 protected function setUp() {
46 $this->useTransaction(TRUE);
50 * Test civicrm_batch_get - success expected.
52 public function testGet() {
54 'id' => $this->batchCreate(),
56 $result = $this->callAPIAndDocument('batch', 'get', $params, __FUNCTION__
, __FILE__
);
57 $this->assertEquals($params['id'], $result['id']);
61 * Test civicrm_batch_create - success expected.
63 public function testCreate() {
65 'name' => 'New_Batch_03',
66 'title' => 'New Batch 03',
67 'description' => 'This is description for New Batch 03',
73 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
74 $this->assertNotNull($result['id']);
75 $this->getAndCheck($params, $result['id'], $this->_entity
);
79 * Test civicrm_batch_create with id.
81 public function testUpdate() {
83 'name' => 'New_Batch_04',
84 'title' => 'New Batch 04',
85 'description' => 'This is description for New Batch 04',
88 'id' => $this->batchCreate(),
91 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
92 $this->assertNotNull($result['id']);
93 $this->getAndCheck($params, $result['id'], $this->_entity
);
97 * Test civicrm_batch_delete using the old $params['batch_id'] syntax.
99 public function testBatchDeleteOldSyntax() {
100 $batchID = $this->batchCreate();
102 'batch_id' => $batchID,
104 $result = $this->callAPISuccess('batch', 'delete', $params);
108 * Test civicrm_batch_delete using the new $params['id'] syntax.
110 public function testBatchDeleteCorrectSyntax() {
111 $batchID = $this->batchCreate();
115 $result = $this->callAPIAndDocument('batch', 'delete', $params, __FUNCTION__
, __FILE__
);