Merge pull request #21943 from mattwire/gccacheignore
[civicrm-core.git] / tests / phpunit / CRM / Event / BAO / ParticipantStatusTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
7d61e75f 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
7d61e75f
TO
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 |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035 11
6a488035
TO
12/**
13 * Test class for CRM_Event_BAO_ParticipantStatus BAO
14 *
6c6e6187 15 * @package CiviCRM
acb109b7 16 * @group headless
6a488035
TO
17 */
18class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase {
19
6a488035
TO
20 /**
21 * create() and deleteParticipantStatusType() method
22 */
00be9182 23 public function testCreateAndDelete() {
6a488035
TO
24
25 // create using required params
9099cab3 26 $params = [
6a488035
TO
27 'name' => 'testStatus',
28 'label' => 'testParticipant',
29 'class' => 'Positive',
30 'weight' => 13,
31 'visibility_id' => 1,
9099cab3 32 ];
6a488035
TO
33
34 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
35 // Checking for participant status type id in db.
36 $statusTypeId = $this->assertDBNotNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id',
37 'id', 'Check DB for status type id'
38 );
39
40 CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($statusType->id);
41 // Checking for participant status type id after delete.
42 $statusTypeId = $this->assertDBNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id',
43 'id', 'Check DB for status type id'
44 );
45 }
46
47 /**
48 * add() method (add and edit modes of participant status type)
49 */
00be9182 50 public function testAddStatusType() {
6a488035 51
9099cab3 52 $params = [
6a488035
TO
53 'name' => 'testStatus',
54 'label' => 'testParticipant',
55 'class' => 'Positive',
56 'is_active' => 1,
57 'is_counted' => 1,
58 'weight' => 13,
59 'visibility_id' => 1,
9099cab3 60 ];
6a488035
TO
61
62 // check for add participant status type
63 $statusType = CRM_Event_BAO_ParticipantStatusType::add($params);
64 foreach ($params as $param => $value) {
65 $this->assertEquals($value, $statusType->$param);
66 }
67
9099cab3 68 $params = [
6a488035
TO
69 'id' => $statusType->id,
70 'name' => 'testStatus',
71 'label' => 'testAlterParticipant',
72 'class' => 'Pending',
73 'is_active' => 0,
74 'is_counted' => 0,
75 'weight' => 14,
76 'visibility_id' => 2,
9099cab3 77 ];
6a488035
TO
78
79 // check for add participant status type
80 $statusType = CRM_Event_BAO_ParticipantStatusType::add($params);
81 foreach ($params as $param => $value) {
82 $this->assertEquals($value, $statusType->$param);
83 }
84 }
85
86 /**
100fef9d 87 * Retrieve() method of participant status type
6a488035 88 */
00be9182 89 public function testRetrieveStatusType() {
6a488035 90
9099cab3 91 $params = [
6a488035
TO
92 'name' => 'testStatus',
93 'label' => 'testParticipant',
94 'class' => 'Positive',
95 'is_active' => 1,
96 'is_counted' => 1,
97 'weight' => 13,
98 'visibility_id' => 1,
9099cab3 99 ];
6a488035
TO
100
101 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
102
103 // retrieve status type
9099cab3
CW
104 $retrieveParams = ['id' => $statusType->id];
105 $default = [];
6a488035
TO
106 $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType::retrieve($retrieveParams, $default);
107
108 // check on retrieve values
109 foreach ($params as $param => $value) {
110 $this->assertEquals($value, $retrieveStatusType->$param);
111 }
112 }
113
114 /**
100fef9d 115 * SetIsActive() method of participant status type
6a488035 116 */
00be9182 117 public function testSetIsActiveStatusType() {
6a488035 118
9099cab3 119 $params = [
6a488035
TO
120 'name' => 'testStatus',
121 'label' => 'testParticipant',
122 'class' => 'Positive',
123 'is_active' => 0,
124 'is_counted' => 1,
125 'weight' => 15,
126 'visibility_id' => 1,
9099cab3 127 ];
6a488035
TO
128
129 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
130 $isActive = 1;
131
132 // set participant status type active
133 CRM_Event_BAO_ParticipantStatusType::setIsActive($statusType->id, $isActive);
134
135 // compare expected value in db
136 $this->assertDBCompareValue('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'is_Active',
137 'id', $isActive, 'Check DB for is_Active value'
138 );
139 }
96025800 140
6a488035 141}