3 +--------------------------------------------------------------------+
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
29 * Test class for CRM_Event_BAO_ParticipantStatus BAO
34 class CRM_Event_BAO_ParticipantStatusTest
extends CiviUnitTestCase
{
37 * Sets up the fixture, for example, opens a network connection.
38 * This method is called before a test is executed.
40 protected function setUp() {
45 * Tears down the fixture, for example, closes a network connection.
46 * This method is called after a test is executed.
48 protected function tearDown() {
52 * create() and deleteParticipantStatusType() method
54 public function testCreateAndDelete() {
56 // create using required params
58 'name' => 'testStatus',
59 'label' => 'testParticipant',
60 'class' => 'Positive',
65 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
66 // Checking for participant status type id in db.
67 $statusTypeId = $this->assertDBNotNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id
, 'id',
68 'id', 'Check DB for status type id'
71 CRM_Event_BAO_ParticipantStatusType
::deleteParticipantStatusType($statusType->id
);
72 // Checking for participant status type id after delete.
73 $statusTypeId = $this->assertDBNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id
, 'id',
74 'id', 'Check DB for status type id'
79 * add() method (add and edit modes of participant status type)
81 public function testAddStatusType() {
84 'name' => 'testStatus',
85 'label' => 'testParticipant',
86 'class' => 'Positive',
93 // check for add participant status type
94 $statusType = CRM_Event_BAO_ParticipantStatusType
::add($params);
95 foreach ($params as $param => $value) {
96 $this->assertEquals($value, $statusType->$param);
100 'id' => $statusType->id
,
101 'name' => 'testStatus',
102 'label' => 'testAlterParticipant',
103 'class' => 'Pending',
107 'visibility_id' => 2,
110 // check for add participant status type
111 $statusType = CRM_Event_BAO_ParticipantStatusType
::add($params);
112 foreach ($params as $param => $value) {
113 $this->assertEquals($value, $statusType->$param);
118 * Retrieve() method of participant status type
120 public function testRetrieveStatusType() {
123 'name' => 'testStatus',
124 'label' => 'testParticipant',
125 'class' => 'Positive',
129 'visibility_id' => 1,
132 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
134 // retrieve status type
135 $retrieveParams = array('id' => $statusType->id
);
137 $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType
::retrieve($retrieveParams, $default);
139 // check on retrieve values
140 foreach ($params as $param => $value) {
141 $this->assertEquals($value, $retrieveStatusType->$param);
146 * SetIsActive() method of participant status type
148 public function testSetIsActiveStatusType() {
151 'name' => 'testStatus',
152 'label' => 'testParticipant',
153 'class' => 'Positive',
157 'visibility_id' => 1,
160 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
163 // set participant status type active
164 CRM_Event_BAO_ParticipantStatusType
::setIsActive($statusType->id
, $isActive);
166 // compare expected value in db
167 $this->assertDBCompareValue('CRM_Event_DAO_ParticipantStatusType', $statusType->id
, 'is_Active',
168 'id', $isActive, 'Check DB for is_Active value'