]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Calls/CallHelperTest.php
Release $ver
[Github/sugarcrm.git] / tests / modules / Calls / CallHelperTest.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37 require_once('modules/Calls/Call.php');
38 require_once('modules/Calls/CallHelper.php');
39
40 class CallHelperTest extends Sugar_PHPUnit_Framework_TestCase
41 {
42     public function setup()
43     {
44         $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
45     }
46     
47     public function tearDown()
48     {
49         unset($GLOBALS['app_list_strings']);
50     }
51     
52     public function providerGetDurationMinutesOptions()
53     {
54         return array(
55             array('EditView',<<<EOHTML
56 <select id="duration_minutes" onchange="SugarWidgetScheduler.update_time();" name="duration_minutes">
57 <OPTION value='0'>00</OPTION>
58 <OPTION selected value='15'>15</OPTION>
59 <OPTION value='30'>30</OPTION>
60 <OPTION value='45'>45</OPTION></select>
61 EOHTML
62                 ),
63             array('MassUpdate',<<<EOHTML
64 <select id="duration_minutes" name="duration_minutes">
65 <OPTION value='0'>00</OPTION>
66 <OPTION selected value='15'>15</OPTION>
67 <OPTION value='30'>30</OPTION>
68 <OPTION value='45'>45</OPTION></select>
69 EOHTML
70                 ),
71             array('QuickCreate',<<<EOHTML
72 <select id="duration_minutes" onchange="SugarWidgetScheduler.update_time();" name="duration_minutes">
73 <OPTION value='0'>00</OPTION>
74 <OPTION selected value='15'>15</OPTION>
75 <OPTION value='30'>30</OPTION>
76 <OPTION value='45'>45</OPTION></select>
77 EOHTML
78                 ),
79
80             array('DetailView','15'),
81         );
82     }
83     
84     /**
85      * @dataProvider providerGetDurationMinutesOptions
86      */
87         public function testGetDurationMinutesOptions(
88             $view,
89             $returnValue
90             )
91     {
92         $focus = new Call();
93         
94         $this->assertEquals(
95             getDurationMinutesOptions($focus,'','',$view),
96             $returnValue
97             );
98     }
99     
100     public function testGetDurationMinutesOptionsNonDefaultValue()
101     {
102         $focus = new Call();
103         $focus->duration_minutes = '30';
104         
105         $this->assertEquals(
106             getDurationMinutesOptions($focus,'','','DetailView'),
107             $focus->duration_minutes
108             );
109     }
110     
111     public function testGetDurationMinutesOptionsFromRequest()
112     {
113         $focus = new Call();
114         $_REQUEST['duration_minutes'] = '45';
115         
116         $this->assertEquals(
117             getDurationMinutesOptions($focus,'','','DetailView'),
118             $_REQUEST['duration_minutes']
119             );
120         
121         unset($_REQUEST['duration_minutes']);
122     }
123     
124     public function testGetDurationMinutesOptionsOtherValues()
125     {
126         $focus = new Call();
127         $focus->date_start = null;
128         $focus->duration_hours = null;
129         $focus->minutes_value_default = null;
130         
131         getDurationMinutesOptions($focus,'','','DetailView');
132         
133         $this->assertEquals($focus->date_start,$GLOBALS['timedate']->to_display_date(gmdate($GLOBALS['timedate']->get_date_time_format())));
134         $this->assertEquals($focus->duration_hours,'0');
135         $this->assertEquals($focus->duration_minutes,'1');
136     }
137     
138     public function providerGetReminderTime()
139     {
140         return array(
141             array('EditView',<<<EOHTML
142 <select id="reminder_time" name="reminder_time">
143 <OPTION value='60'>1 minute prior</OPTION>
144 <OPTION value='300'>5 minutes prior</OPTION>
145 <OPTION value='600'>10 minutes prior</OPTION>
146 <OPTION value='900'>15 minutes prior</OPTION>
147 <OPTION value='1800'>30 minutes prior</OPTION>
148 <OPTION value='3600'>1 hour prior</OPTION></select>
149 EOHTML
150                 ),
151             array('MassUpdate',<<<EOHTML
152 <select id="reminder_time" name="reminder_time">
153 <OPTION value='60'>1 minute prior</OPTION>
154 <OPTION value='300'>5 minutes prior</OPTION>
155 <OPTION value='600'>10 minutes prior</OPTION>
156 <OPTION value='900'>15 minutes prior</OPTION>
157 <OPTION value='1800'>30 minutes prior</OPTION>
158 <OPTION value='3600'>1 hour prior</OPTION></select>
159 EOHTML
160                 ),
161             array('SubpanelCreates',<<<EOHTML
162 <select id="reminder_time" name="reminder_time">
163 <OPTION value='60'>1 minute prior</OPTION>
164 <OPTION value='300'>5 minutes prior</OPTION>
165 <OPTION value='600'>10 minutes prior</OPTION>
166 <OPTION value='900'>15 minutes prior</OPTION>
167 <OPTION value='1800'>30 minutes prior</OPTION>
168 <OPTION value='3600'>1 hour prior</OPTION></select>
169 EOHTML
170                 ),
171             array('QuickCreate',<<<EOHTML
172 <select id="reminder_time" name="reminder_time">
173 <OPTION value='60'>1 minute prior</OPTION>
174 <OPTION value='300'>5 minutes prior</OPTION>
175 <OPTION value='600'>10 minutes prior</OPTION>
176 <OPTION value='900'>15 minutes prior</OPTION>
177 <OPTION value='1800'>30 minutes prior</OPTION>
178 <OPTION value='3600'>1 hour prior</OPTION></select>
179 EOHTML
180                 ),
181
182             array('DetailView',''),
183         );
184     }
185     
186     /**
187      * @dataProvider providerGetReminderTime
188      */
189         public function testGetReminderTime($view,$returnValue)
190     {
191         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
192         $focus = new Call();
193         
194         $this->assertEquals( getReminderTime($focus,'','',$view),$returnValue);
195     }
196     
197     public function testGetReminderTimeNonDefaultValue()
198     {
199         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
200         $focus = new Call();
201         $focus->reminder_time = '600';
202         
203         $this->assertEquals(
204             getReminderTime($focus,'','','EditView'),
205             <<<EOHTML
206 <select id="reminder_time" name="reminder_time">
207 <OPTION value='60'>1 minute prior</OPTION>
208 <OPTION value='300'>5 minutes prior</OPTION>
209 <OPTION selected value='600'>10 minutes prior</OPTION>
210 <OPTION value='900'>15 minutes prior</OPTION>
211 <OPTION value='1800'>30 minutes prior</OPTION>
212 <OPTION value='3600'>1 hour prior</OPTION></select>
213 EOHTML
214             );
215     }
216     
217     public function testGetReminderTimeNonDefaultValueDetailView()
218     {
219         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
220
221         $focus = new Call();
222         $focus->reminder_time = '300';
223         
224         $this->assertEquals( getReminderTime($focus,'','','DetailView'),'5 minutes prior');
225     }
226     
227     public function testGetReminderTimeFromRequest()
228     {
229         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
230         $focus = new Call();
231         $_REQUEST['reminder_time'] = '900';
232         $_REQUEST['full_form'] = true;
233         
234         $this->assertEquals(
235             getReminderTime($focus,'','','EditView'),
236             <<<EOHTML
237 <select id="reminder_time" name="reminder_time">
238 <OPTION value='60'>1 minute prior</OPTION>
239 <OPTION value='300'>5 minutes prior</OPTION>
240 <OPTION value='600'>10 minutes prior</OPTION>
241 <OPTION selected value='900'>15 minutes prior</OPTION>
242 <OPTION value='1800'>30 minutes prior</OPTION>
243 <OPTION value='3600'>1 hour prior</OPTION></select>
244 EOHTML
245             );
246         
247         unset($_REQUEST['reminder_time']);
248         unset($_REQUEST['full_form']);
249     }
250     
251     public function testGetReminderTimeFromValue()
252     {
253         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
254         $focus = new Call();
255         unset($focus->reminder_time);
256         
257         $this->assertEquals(
258             getReminderTime($focus,'','1800','EditView'),
259             <<<EOHTML
260 <select id="reminder_time" name="reminder_time">
261 <OPTION value='60'>1 minute prior</OPTION>
262 <OPTION value='300'>5 minutes prior</OPTION>
263 <OPTION value='600'>10 minutes prior</OPTION>
264 <OPTION value='900'>15 minutes prior</OPTION>
265 <OPTION selected value='1800'>30 minutes prior</OPTION>
266 <OPTION value='3600'>1 hour prior</OPTION></select>
267 EOHTML
268             );
269     }
270 }