tests/phpunit/** - Remove unnecessary "require_once" statements
[civicrm-core.git] / tests / phpunit / CRM / Event / BAO / ParticipantStatusTest.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
81621fee 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
6a488035
TO
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035 27
6a488035
TO
28/**
29 * Test class for CRM_Event_BAO_ParticipantStatus BAO
30 *
6c6e6187 31 * @package CiviCRM
6a488035
TO
32 */
33class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase {
34
35 /**
36 * Sets up the fixture, for example, opens a network connection.
37 * This method is called before a test is executed.
6a488035
TO
38 */
39 protected function setUp() {
40 parent::setUp();
41 }
42
43 /**
44 * Tears down the fixture, for example, closes a network connection.
45 * This method is called after a test is executed.
6a488035 46 */
6c6e6187
TO
47 protected function tearDown() {
48 }
6a488035 49
6a488035
TO
50 /**
51 * create() and deleteParticipantStatusType() method
52 */
00be9182 53 public function testCreateAndDelete() {
6a488035
TO
54
55 // create using required params
56 $params = array(
57 'name' => 'testStatus',
58 'label' => 'testParticipant',
59 'class' => 'Positive',
60 'weight' => 13,
61 'visibility_id' => 1,
62 );
63
64 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
65 // Checking for participant status type id in db.
66 $statusTypeId = $this->assertDBNotNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id',
67 'id', 'Check DB for status type id'
68 );
69
70 CRM_Event_BAO_ParticipantStatusType::deleteParticipantStatusType($statusType->id);
71 // Checking for participant status type id after delete.
72 $statusTypeId = $this->assertDBNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id',
73 'id', 'Check DB for status type id'
74 );
75 }
76
77 /**
78 * add() method (add and edit modes of participant status type)
79 */
00be9182 80 public function testAddStatusType() {
6a488035
TO
81
82 $params = array(
83 'name' => 'testStatus',
84 'label' => 'testParticipant',
85 'class' => 'Positive',
86 'is_active' => 1,
87 'is_counted' => 1,
88 'weight' => 13,
89 'visibility_id' => 1,
90 );
91
92 // check for add participant status type
93 $statusType = CRM_Event_BAO_ParticipantStatusType::add($params);
94 foreach ($params as $param => $value) {
95 $this->assertEquals($value, $statusType->$param);
96 }
97
98 $params = array(
99 'id' => $statusType->id,
100 'name' => 'testStatus',
101 'label' => 'testAlterParticipant',
102 'class' => 'Pending',
103 'is_active' => 0,
104 'is_counted' => 0,
105 'weight' => 14,
106 'visibility_id' => 2,
107 );
108
109 // check for add participant status type
110 $statusType = CRM_Event_BAO_ParticipantStatusType::add($params);
111 foreach ($params as $param => $value) {
112 $this->assertEquals($value, $statusType->$param);
113 }
114 }
115
116 /**
100fef9d 117 * Retrieve() method of participant status type
6a488035 118 */
00be9182 119 public function testRetrieveStatusType() {
6a488035
TO
120
121 $params = array(
122 'name' => 'testStatus',
123 'label' => 'testParticipant',
124 'class' => 'Positive',
125 'is_active' => 1,
126 'is_counted' => 1,
127 'weight' => 13,
128 'visibility_id' => 1,
129 );
130
131 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
132
133 // retrieve status type
92915c55
TO
134 $retrieveParams = array('id' => $statusType->id);
135 $default = array();
6a488035
TO
136 $retrieveStatusType = CRM_Event_BAO_ParticipantStatusType::retrieve($retrieveParams, $default);
137
138 // check on retrieve values
139 foreach ($params as $param => $value) {
140 $this->assertEquals($value, $retrieveStatusType->$param);
141 }
142 }
143
144 /**
100fef9d 145 * SetIsActive() method of participant status type
6a488035 146 */
00be9182 147 public function testSetIsActiveStatusType() {
6a488035
TO
148
149 $params = array(
150 'name' => 'testStatus',
151 'label' => 'testParticipant',
152 'class' => 'Positive',
153 'is_active' => 0,
154 'is_counted' => 1,
155 'weight' => 15,
156 'visibility_id' => 1,
157 );
158
159 $statusType = CRM_Event_BAO_ParticipantStatusType::create($params);
160 $isActive = 1;
161
162 // set participant status type active
163 CRM_Event_BAO_ParticipantStatusType::setIsActive($statusType->id, $isActive);
164
165 // compare expected value in db
166 $this->assertDBCompareValue('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'is_Active',
167 'id', $isActive, 'Check DB for is_Active value'
168 );
169 }
96025800 170
6a488035 171}