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;
27 * @throws \CRM_Core_Exception
28 * @throws \CiviCRM_API3_Exception
30 public function setUp(): void
{
32 $this->useTransaction();
34 $entityParams = ['contact_id' => $this->individualCreate()];
36 $this->_entity
= 'EntityBatch';
37 $this->_entityID
= $this->contributionCreate($entityParams);
38 $this->_batchID
= $this->batchCreate();
40 'entity_id' => $this->_entityID
,
41 'batch_id' => $this->_batchID
,
42 'entity_table' => 'civicrm_financial_trxn',
46 public function testCreateEntityBatch() {
47 $result = $this->callAPIAndDocument($this->_entity
, 'create', $this->params
, __FUNCTION__
, __FILE__
);
48 $this->assertEquals(1, $result['count']);
49 $this->getAndCheck($this->params
, $result['id'], $this->_entity
);
50 $this->assertNotNull($result['values'][$result['id']]['id']);
53 public function testGetEntityBatch() {
54 $result = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
55 $result = $this->callAPIAndDocument($this->_entity
, 'get', $this->params
, __FUNCTION__
, __FILE__
);
56 $this->assertEquals(1, $result['count']);
57 $this->assertNotNull($result['values'][$result['id']]['id']);
58 $this->callAPISuccess($this->_entity
, 'delete', ['id' => $result['id']]);
61 public function testDeleteEntityBatch() {
62 $result = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
63 $deleteParams = ['id' => $result['id']];
64 $result = $this->callAPIAndDocument($this->_entity
, 'delete', $deleteParams, __FUNCTION__
, __FILE__
);
65 $checkDeleted = $this->callAPISuccess($this->_entity
, 'get', []);
66 $this->assertEquals(0, $checkDeleted['count']);