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
{
22 public $DBResetRequired = FALSE;
25 * @throws \CRM_Core_Exception
26 * @throws \CiviCRM_API3_Exception
28 public function setUp(): void
{
30 $this->useTransaction();
32 $entityParams = ['contact_id' => $this->individualCreate()];
34 $this->_entity
= 'EntityBatch';
36 'entity_id' => $this->contributionCreate($entityParams),
37 'batch_id' => $this->batchCreate(),
38 'entity_table' => 'civicrm_financial_trxn',
43 * @throws \CRM_Core_Exception
45 public function testCreateEntityBatch(): void
{
46 $result = $this->callAPIAndDocument($this->_entity
, 'create', $this->params
, __FUNCTION__
, __FILE__
);
47 $this->assertEquals(1, $result['count']);
48 $this->getAndCheck($this->params
, $result['id'], $this->_entity
);
49 $this->assertNotNull($result['values'][$result['id']]['id']);
53 * @throws \CRM_Core_Exception
55 public function testGetEntityBatch(): void
{
56 $this->callAPISuccess($this->_entity
, 'create', $this->params
);
57 $result = $this->callAPIAndDocument($this->_entity
, 'get', $this->params
, __FUNCTION__
, __FILE__
);
58 $this->assertEquals(1, $result['count']);
59 $this->assertNotNull($result['values'][$result['id']]['id']);
60 $this->callAPISuccess($this->_entity
, 'delete', ['id' => $result['id']]);
64 * @throws \CRM_Core_Exception
66 public function testDeleteEntityBatch(): void
{
67 $result = $this->callAPISuccess($this->_entity
, 'create', $this->params
);
68 $deleteParams = ['id' => $result['id']];
69 $this->callAPIAndDocument($this->_entity
, 'delete', $deleteParams, __FUNCTION__
, __FILE__
);
70 $checkDeleted = $this->callAPISuccess($this->_entity
, 'get', []);
71 $this->assertEquals(0, $checkDeleted['count']);