Merge pull request #17294 from agh1/sr-rel-perms
[civicrm-core.git] / tests / phpunit / api / v3 / ParticipantStatusTypeTest.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 /**
13 * Class api_v3_ParticipantStatusTypeTest
14 * @group headless
15 */
16 class api_v3_ParticipantStatusTypeTest extends CiviUnitTestCase {
17 protected $_apiversion;
18 protected $params;
19 protected $id;
20
21 public $DBResetRequired = FALSE;
22
23 public function setUp() {
24 $this->_apiversion = 3;
25 $this->params = [
26 'name' => 'test status',
27 'label' => 'I am a test',
28 'class' => 'Positive',
29 'is_reserved' => 0,
30 'is_active' => 1,
31 'is_counted' => 1,
32 'visibility_id' => 1,
33 'weight' => 10,
34 ];
35 parent::setUp();
36 $this->useTransaction(TRUE);
37 }
38
39 public function testCreateParticipantStatusType() {
40 $result = $this->callAPIAndDocument('participant_status_type', 'create', $this->params, __FUNCTION__, __FILE__);
41 $this->assertEquals(1, $result['count']);
42 $this->assertNotNull($result['values'][$result['id']]['id']);
43 }
44
45 public function testGetParticipantStatusType() {
46 $result = $this->callAPIAndDocument('participant_status_type', 'create', $this->params, __FUNCTION__, __FILE__);
47 $this->assertEquals(1, $result['count']);
48
49 $result = $this->callAPIAndDocument('participant_status_type', 'get', $this->params, __FUNCTION__, __FILE__);
50 $this->assertEquals(1, $result['count']);
51 $this->assertNotNull($result['values'][$result['id']]['id']);
52 $this->id = $result['id'];
53 }
54
55 public function testDeleteParticipantStatusType() {
56
57 $ParticipantStatusType = $this->callAPISuccess('ParticipantStatusType', 'Create', $this->params);
58 $entity = $this->callAPISuccess('participant_status_type', 'get', []);
59 $result = $this->callAPIAndDocument('participant_status_type', 'delete', ['id' => $ParticipantStatusType['id']], __FUNCTION__, __FILE__);
60 $getCheck = $this->callAPISuccess('ParticipantStatusType', 'GET', ['id' => $ParticipantStatusType['id']]);
61 $checkDeleted = $this->callAPISuccess('ParticipantStatusType', 'Get', []);
62 $this->assertEquals($entity['count'] - 1, $checkDeleted['count']);
63 }
64
65 }