Merge pull request #17706 from demeritcowboy/mysql-ssl-alt
[civicrm-core.git] / tests / phpunit / api / v3 / EntityBatchTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
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 +--------------------------------------------------------------------+ */
10
11 /**
12 * Test APIv3 civicrm_entity_batch_* functions
13 *
14 * @package CiviCRM_APIv3
15 * @group headless
16 */
17 class api_v3_EntityBatchTest extends CiviUnitTestCase {
18
19 protected $_apiversion = 3;
20 protected $params;
21 protected $id;
22 protected $_entity;
23
24 public $DBResetRequired = FALSE;
25
26 public function setUp() {
27 parent::setUp();
28 $this->useTransaction(TRUE);
29
30 $entityParams = ['contact_id' => 1];
31
32 $this->_entity = 'EntityBatch';
33 $this->_entityID = $this->contributionCreate($entityParams);
34 $this->_batchID = $this->batchCreate();
35 $this->params = [
36 'entity_id' => $this->_entityID,
37 'batch_id' => $this->_batchID,
38 'entity_table' => 'civicrm_financial_trxn',
39 ];
40 }
41
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']);
47 }
48
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']]);
55 }
56
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']);
63 }
64
65 }