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 SugarTestHelper::setUp('beanFiles');
45 SugarTestHelper::setUp('beanList');
46 SugarTestHelper::setUp('app_list_strings');
47 SugarTestHelper::setUp('current_user');
50 public function tearDown()
52 SugarTestHelper::tearDown();
55 public function providerGetDurationMinutesOptions()
58 array('EditView',<<<EOHTML
59 <select id="duration_minutes" onchange="SugarWidgetScheduler.update_time();" name="duration_minutes">
60 <OPTION value='0'>00</OPTION>
61 <OPTION selected value='15'>15</OPTION>
62 <OPTION value='30'>30</OPTION>
63 <OPTION value='45'>45</OPTION></select>
66 array('MassUpdate',<<<EOHTML
67 <select id="duration_minutes" name="duration_minutes">
68 <OPTION value='0'>00</OPTION>
69 <OPTION selected value='15'>15</OPTION>
70 <OPTION value='30'>30</OPTION>
71 <OPTION value='45'>45</OPTION></select>
74 array('QuickCreate',<<<EOHTML
75 <select id="duration_minutes" onchange="SugarWidgetScheduler.update_time();" name="duration_minutes">
76 <OPTION value='0'>00</OPTION>
77 <OPTION selected value='15'>15</OPTION>
78 <OPTION value='30'>30</OPTION>
79 <OPTION value='45'>45</OPTION></select>
83 array('DetailView','15'),
88 * @dataProvider providerGetDurationMinutesOptions
90 public function testGetDurationMinutesOptions(
98 getDurationMinutesOptions($focus,'','',$view),
103 public function testGetDurationMinutesOptionsNonDefaultValue()
106 $focus->duration_minutes = '30';
109 getDurationMinutesOptions($focus,'','','DetailView'),
110 $focus->duration_minutes
114 public function testGetDurationMinutesOptionsFromRequest()
117 $_REQUEST['duration_minutes'] = '45';
120 getDurationMinutesOptions($focus,'','','DetailView'),
121 $_REQUEST['duration_minutes']
124 unset($_REQUEST['duration_minutes']);
127 public function testGetDurationMinutesOptionsOtherValues()
130 $focus->date_start = null;
131 $focus->duration_hours = null;
132 $focus->minutes_value_default = null;
134 getDurationMinutesOptions($focus,'','','DetailView');
136 $this->assertEquals($focus->date_start,$GLOBALS['timedate']->to_display_date(gmdate($GLOBALS['timedate']->get_date_time_format())));
137 $this->assertEquals($focus->duration_hours,'0');
138 $this->assertEquals($focus->duration_minutes,'1');
141 public function providerGetReminderTime()
144 array('EditView',<<<EOHTML
145 <select id="reminder_time" name="reminder_time">
146 <OPTION value='60'>1 minute prior</OPTION>
147 <OPTION value='300'>5 minutes prior</OPTION>
148 <OPTION value='600'>10 minutes prior</OPTION>
149 <OPTION value='900'>15 minutes prior</OPTION>
150 <OPTION value='1800'>30 minutes prior</OPTION>
151 <OPTION value='3600'>1 hour prior</OPTION></select>
154 array('MassUpdate',<<<EOHTML
155 <select id="reminder_time" name="reminder_time">
156 <OPTION value='60'>1 minute prior</OPTION>
157 <OPTION value='300'>5 minutes prior</OPTION>
158 <OPTION value='600'>10 minutes prior</OPTION>
159 <OPTION value='900'>15 minutes prior</OPTION>
160 <OPTION value='1800'>30 minutes prior</OPTION>
161 <OPTION value='3600'>1 hour prior</OPTION></select>
164 array('SubpanelCreates',<<<EOHTML
165 <select id="reminder_time" name="reminder_time">
166 <OPTION value='60'>1 minute prior</OPTION>
167 <OPTION value='300'>5 minutes prior</OPTION>
168 <OPTION value='600'>10 minutes prior</OPTION>
169 <OPTION value='900'>15 minutes prior</OPTION>
170 <OPTION value='1800'>30 minutes prior</OPTION>
171 <OPTION value='3600'>1 hour prior</OPTION></select>
174 array('QuickCreate',<<<EOHTML
175 <select id="reminder_time" name="reminder_time">
176 <OPTION value='60'>1 minute prior</OPTION>
177 <OPTION value='300'>5 minutes prior</OPTION>
178 <OPTION value='600'>10 minutes prior</OPTION>
179 <OPTION value='900'>15 minutes prior</OPTION>
180 <OPTION value='1800'>30 minutes prior</OPTION>
181 <OPTION value='3600'>1 hour prior</OPTION></select>
185 array('DetailView',''),
190 * @dataProvider providerGetReminderTime
192 public function testGetReminderTime($view,$returnValue)
194 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
197 $this->assertEquals( getReminderTime($focus,'','',$view),$returnValue);
200 public function testGetReminderTimeNonDefaultValue()
202 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
204 $focus->reminder_time = '600';
207 getReminderTime($focus,'','','EditView'),
209 <select id="reminder_time" name="reminder_time">
210 <OPTION value='60'>1 minute prior</OPTION>
211 <OPTION value='300'>5 minutes prior</OPTION>
212 <OPTION selected value='600'>10 minutes prior</OPTION>
213 <OPTION value='900'>15 minutes prior</OPTION>
214 <OPTION value='1800'>30 minutes prior</OPTION>
215 <OPTION value='3600'>1 hour prior</OPTION></select>
220 public function testGetReminderTimeNonDefaultValueDetailView()
222 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
225 $focus->reminder_time = '300';
227 $this->assertEquals( getReminderTime($focus,'','','DetailView'),'5 minutes prior');
230 public function testGetReminderTimeFromRequest()
232 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
234 $_REQUEST['reminder_time'] = '900';
235 $_REQUEST['full_form'] = true;
238 getReminderTime($focus,'','','EditView'),
240 <select id="reminder_time" name="reminder_time">
241 <OPTION value='60'>1 minute prior</OPTION>
242 <OPTION value='300'>5 minutes prior</OPTION>
243 <OPTION value='600'>10 minutes prior</OPTION>
244 <OPTION selected value='900'>15 minutes prior</OPTION>
245 <OPTION value='1800'>30 minutes prior</OPTION>
246 <OPTION value='3600'>1 hour prior</OPTION></select>
250 unset($_REQUEST['reminder_time']);
251 unset($_REQUEST['full_form']);
254 public function testGetReminderTimeFromValue()
256 $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
258 unset($focus->reminder_time);
261 getReminderTime($focus,'','1800','EditView'),
263 <select id="reminder_time" name="reminder_time">
264 <OPTION value='60'>1 minute prior</OPTION>
265 <OPTION value='300'>5 minutes prior</OPTION>
266 <OPTION value='600'>10 minutes prior</OPTION>
267 <OPTION value='900'>15 minutes prior</OPTION>
268 <OPTION selected value='1800'>30 minutes prior</OPTION>
269 <OPTION value='3600'>1 hour prior</OPTION></select>