3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Test class for Batch API - civicrm_batch_*
15 * @package CiviCRM_APIv3
18 class api_v3_BatchTest
extends CiviUnitTestCase
{
20 protected $_params = [];
21 protected $_entity = 'batch';
24 * Sets up the fixture, for example, opens a network connection.
26 * This method is called before a test is executed.
28 protected function setUp() {
30 $this->useTransaction(TRUE);
34 * Test civicrm_batch_get - success expected.
36 public function testGet() {
38 'id' => $this->batchCreate(),
40 $result = $this->callAPIAndDocument('batch', 'get', $params, __FUNCTION__
, __FILE__
);
41 $this->assertEquals($params['id'], $result['id']);
45 * Test civicrm_batch_create - success expected.
47 public function testCreate() {
49 'name' => 'New_Batch_03',
50 'title' => 'New Batch 03',
51 'description' => 'This is description for New Batch 03',
57 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
58 $this->assertNotNull($result['id']);
59 $this->getAndCheck($params, $result['id'], $this->_entity
);
63 * Test civicrm_batch_create with id.
65 public function testUpdate() {
67 'name' => 'New_Batch_04',
68 'title' => 'New Batch 04',
69 'description' => 'This is description for New Batch 04',
72 'id' => $this->batchCreate(),
75 $result = $this->callAPIAndDocument('batch', 'create', $params, __FUNCTION__
, __FILE__
);
76 $this->assertNotNull($result['id']);
77 $this->getAndCheck($params, $result['id'], $this->_entity
);
81 * Test civicrm_batch_delete using the old $params['batch_id'] syntax.
83 public function testBatchDeleteOldSyntax() {
84 $batchID = $this->batchCreate();
86 'batch_id' => $batchID,
88 $result = $this->callAPISuccess('batch', 'delete', $params);
92 * Test civicrm_batch_delete using the new $params['id'] syntax.
94 public function testBatchDeleteCorrectSyntax() {
95 $batchID = $this->batchCreate();
99 $result = $this->callAPIAndDocument('batch', 'delete', $params, __FUNCTION__
, __FILE__
);