3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
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 require_once 'CiviTest/CiviUnitTestCase.php';
32 * Test class for CRM_Event_BAO_ParticipantStatus BAO
36 class CRM_Event_BAO_ParticipantStatusTest
extends CiviUnitTestCase
{
39 * Sets up the fixture, for example, opens a network connection.
40 * This method is called before a test is executed.
42 protected function setUp() {
47 * Tears down the fixture, for example, closes a network connection.
48 * This method is called after a test is executed.
50 protected function tearDown() {
54 * create() and deleteParticipantStatusType() method
56 public function testCreateAndDelete() {
58 // create using required params
60 'name' => 'testStatus',
61 'label' => 'testParticipant',
62 'class' => 'Positive',
67 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
68 // Checking for participant status type id in db.
69 $statusTypeId = $this->assertDBNotNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id
, 'id',
70 'id', 'Check DB for status type id'
73 CRM_Event_BAO_ParticipantStatusType
::deleteParticipantStatusType($statusType->id
);
74 // Checking for participant status type id after delete.
75 $statusTypeId = $this->assertDBNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id
, 'id',
76 'id', 'Check DB for status type id'
81 * add() method (add and edit modes of participant status type)
83 public function testAddStatusType() {
86 'name' => 'testStatus',
87 'label' => 'testParticipant',
88 'class' => 'Positive',
95 // check for add participant status type
96 $statusType = CRM_Event_BAO_ParticipantStatusType
::add($params);
97 foreach ($params as $param => $value) {
98 $this->assertEquals($value, $statusType->$param);
102 'id' => $statusType->id
,
103 'name' => 'testStatus',
104 'label' => 'testAlterParticipant',
105 'class' => 'Pending',
109 'visibility_id' => 2,
112 // check for add participant status type
113 $statusType = CRM_Event_BAO_ParticipantStatusType
::add($params);
114 foreach ($params as $param => $value) {
115 $this->assertEquals($value, $statusType->$param);
120 * Retrieve() method of participant status type
122 public function testRetrieveStatusType() {
125 'name' => 'testStatus',
126 'label' => 'testParticipant',
127 'class' => 'Positive',
131 'visibility_id' => 1,
134 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
136 // retrieve status type
137 $retrieveParams = array('id' => $statusType->id
);
139 $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType
::retrieve($retrieveParams, $default);
141 // check on retrieve values
142 foreach ($params as $param => $value) {
143 $this->assertEquals($value, $retrieveStatusType->$param);
148 * SetIsActive() method of participant status type
150 public function testSetIsActiveStatusType() {
153 'name' => 'testStatus',
154 'label' => 'testParticipant',
155 'class' => 'Positive',
159 'visibility_id' => 1,
162 $statusType = CRM_Event_BAO_ParticipantStatusType
::create($params);
165 // set participant status type active
166 CRM_Event_BAO_ParticipantStatusType
::setIsActive($statusType->id
, $isActive);
168 // compare expected value in db
169 $this->assertDBCompareValue('CRM_Event_DAO_ParticipantStatusType', $statusType->id
, 'is_Active',
170 'id', $isActive, 'Check DB for is_Active value'