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 +--------------------------------------------------------------------+
13 * Test class for CRM_Event_BAO_ParticipantStatus BAO
18 class CRM_Event_BAO_ParticipantStatusTest
extends CiviUnitTestCase
{
21 * create() and deleteParticipantStatusType() method
23 public function testCreateAndDelete() {
25 // create using required params
27 'name' => 'testStatus',
28 'label' => 'testParticipant',
29 'class' => 'Positive',
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'
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'
48 * add() method (add and edit modes of participant status type)
50 public function testAddStatusType() {
53 'name' => 'testStatus',
54 'label' => 'testParticipant',
55 'class' => 'Positive',
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);
69 'id' => $statusType->id
,
70 'name' => 'testStatus',
71 'label' => 'testAlterParticipant',
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);
87 * Retrieve() method of participant status type
89 public function testRetrieveStatusType() {
92 'name' => 'testStatus',
93 'label' => 'testParticipant',
94 'class' => 'Positive',
101 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
103 // retrieve status type
104 $retrieveParams = ['id' => $statusType->id
];
106 $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType
::retrieve($retrieveParams, $default);
108 // check on retrieve values
109 foreach ($params as $param => $value) {
110 $this->assertEquals($value, $retrieveStatusType->$param);
115 * SetIsActive() method of participant status type
117 public function testSetIsActiveStatusType() {
120 'name' => 'testStatus',
121 'label' => 'testParticipant',
122 'class' => 'Positive',
126 'visibility_id' => 1,
129 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
132 // set participant status type active
133 CRM_Event_BAO_ParticipantStatusType
::setIsActive($statusType->id
, $isActive);
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'