2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
37 require_once('modules/Calls/Call.php');
38 require_once('modules/Calls/CallHelper.php');
40 class CallHelperTest extends Sugar_PHPUnit_Framework_TestCase
42 public function setup()
44 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
47 public function tearDown()
49 unset($GLOBALS['app_list_strings']);
52 public function providerGetDurationMinutesOptions()
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>
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>
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>
80 array('DetailView','15'),
85 * @dataProvider providerGetDurationMinutesOptions
87 public function testGetDurationMinutesOptions(
95 getDurationMinutesOptions($focus,'','',$view),
100 public function testGetDurationMinutesOptionsNonDefaultValue()
103 $focus->duration_minutes = '30';
106 getDurationMinutesOptions($focus,'','','DetailView'),
107 $focus->duration_minutes
111 public function testGetDurationMinutesOptionsFromRequest()
114 $_REQUEST['duration_minutes'] = '45';
117 getDurationMinutesOptions($focus,'','','DetailView'),
118 $_REQUEST['duration_minutes']
121 unset($_REQUEST['duration_minutes']);
124 public function testGetDurationMinutesOptionsOtherValues()
127 $focus->date_start = null;
128 $focus->duration_hours = null;
129 $focus->minutes_value_default = null;
131 getDurationMinutesOptions($focus,'','','DetailView');
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');
138 public function providerGetReminderTime()
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>
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>
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>
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>
182 array('DetailView',''),
187 * @dataProvider providerGetReminderTime
189 public function testGetReminderTime($view,$returnValue)
191 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
194 $this->assertEquals( getReminderTime($focus,'','',$view),$returnValue);
197 public function testGetReminderTimeNonDefaultValue()
199 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
201 $focus->reminder_time = '600';
204 getReminderTime($focus,'','','EditView'),
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>
217 public function testGetReminderTimeNonDefaultValueDetailView()
219 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
222 $focus->reminder_time = '300';
224 $this->assertEquals( getReminderTime($focus,'','','DetailView'),'5 minutes prior');
227 public function testGetReminderTimeFromRequest()
229 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
231 $_REQUEST['reminder_time'] = '900';
232 $_REQUEST['full_form'] = true;
235 getReminderTime($focus,'','','EditView'),
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>
247 unset($_REQUEST['reminder_time']);
248 unset($_REQUEST['full_form']);
251 public function testGetReminderTimeFromValue()
253 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
255 unset($focus->reminder_time);
258 getReminderTime($focus,'','1800','EditView'),
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>