commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / civicrm / tests / phpunit / CRM / Event / BAO / ParticipantStatusTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26 */
27
28
29 require_once 'CiviTest/CiviUnitTestCase.php';
30
31 /**
32 * Test class for CRM_Event_BAO_ParticipantStatus BAO
33 *
34 * @package CiviCRM
35 */
36 class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase {
37
38 /**
39 * Sets up the fixture, for example, opens a network connection.
40 * This method is called before a test is executed.
41 */
42 protected function setUp() {
43 parent::setUp();
44 }
45
46 /**
47 * Tears down the fixture, for example, closes a network connection.
48 * This method is called after a test is executed.
49 */
50 protected function tearDown() {
51 }
52
53 /**
54 * create() and deleteParticipantStatusType() method
55 */
56 public function testCreateAndDelete() {
57
58 // create using required params
59 $params = array(
60 'name' => 'testStatus',
61 'label' => 'testParticipant',
62 'class' => 'Positive',
63 'weight' => 13,
64 'visibility_id' => 1,
65 );
66
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'
71 );
72
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'
77 );
78 }
79
80 /**
81 * add() method (add and edit modes of participant status type)
82 */
83 public function testAddStatusType() {
84
85 $params = array(
86 'name' => 'testStatus',
87 'label' => 'testParticipant',
88 'class' => 'Positive',
89 'is_active' => 1,
90 'is_counted' => 1,
91 'weight' => 13,
92 'visibility_id' => 1,
93 );
94
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);
99 }
100
101 $params = array(
102 'id' => $statusType->id,
103 'name' => 'testStatus',
104 'label' => 'testAlterParticipant',
105 'class' => 'Pending',
106 'is_active' => 0,
107 'is_counted' => 0,
108 'weight' => 14,
109 'visibility_id' => 2,
110 );
111
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);
116 }
117 }
118
119 /**
120 * Retrieve() method of participant status type
121 */
122 public function testRetrieveStatusType() {
123
124 $params = array(
125 'name' => 'testStatus',
126 'label' => 'testParticipant',
127 'class' => 'Positive',
128 'is_active' => 1,
129 'is_counted' => 1,
130 'weight' => 13,
131 'visibility_id' => 1,
132 );
133
134 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
135
136 // retrieve status type
137 $retrieveParams = array('id' => $statusType->id);
138 $default = array();
139 $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType::retrieve($retrieveParams, $default);
140
141 // check on retrieve values
142 foreach ($params as $param => $value) {
143 $this->assertEquals($value, $retrieveStatusType->$param);
144 }
145 }
146
147 /**
148 * SetIsActive() method of participant status type
149 */
150 public function testSetIsActiveStatusType() {
151
152 $params = array(
153 'name' => 'testStatus',
154 'label' => 'testParticipant',
155 'class' => 'Positive',
156 'is_active' => 0,
157 'is_counted' => 1,
158 'weight' => 15,
159 'visibility_id' => 1,
160 );
161
162 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
163 $isActive = 1;
164
165 // set participant status type active
166 CRM_Event_BAO_ParticipantStatusType::setIsActive($statusType->id, $isActive);
167
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'
171 );
172 }
173
174 }