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 +--------------------------------------------------------------------+ */
12 * Test APIv3 civicrm_entity_batch_* functions
14 * @package CiviCRM_APIv3
17 class api_v3_EntityBatchTest
extends CiviUnitTestCase
{
19 protected $_apiversion = 3;
24 public $DBResetRequired = FALSE;
26 public function setUp() {
28 $this->useTransaction(TRUE);
30 $entityParams = ['contact_id' => 1];
32 $this->_entity
= 'EntityBatch';
33 $this->_entityID
= $this->contributionCreate($entityParams);
34 $this->_batchID
= $this->batchCreate();
36 'entity_id' => $this->_entityID
,
37 'batch_id' => $this->_batchID
,
38 'entity_table' => 'civicrm_financial_trxn',
42 public function testCreateEntityBatch() {
43 $result = $this->callAPIAndDocument($this->_entity
, 'create', $this->params
, __FUNCTION__
, __FILE__
);
44 $this->assertEquals(1, $result['count']);
45 $this->getAndCheck($this->params
, $result['id'], $this->_entity
);
46 $this->assertNotNull($result['values'][$result['id']]['id']);
49 public function testGetEntityBatch() {
50 $result = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
51 $result = $this->callAPIAndDocument($this->_entity
, 'get', $this->params
, __FUNCTION__
, __FILE__
);
52 $this->assertEquals(1, $result['count']);
53 $this->assertNotNull($result['values'][$result['id']]['id']);
54 $this->callAPISuccess($this->_entity
, 'delete', ['id' => $result['id']]);
57 public function testDeleteEntityBatch() {
58 $result = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
59 $deleteParams = ['id' => $result['id']];
60 $result = $this->callAPIAndDocument($this->_entity
, 'delete', $deleteParams, __FUNCTION__
, __FILE__
);
61 $checkDeleted = $this->callAPISuccess($this->_entity
, 'get', []);
62 $this->assertEquals(0, $checkDeleted['count']);