]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/Calls/CallHelperTest.php
Release 6.5.3
[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         SugarTestHelper::setUp('beanFiles');
45         SugarTestHelper::setUp('beanList');
46         SugarTestHelper::setUp('app_list_strings');
47         SugarTestHelper::setUp('current_user');
48     }
49     
50     public function tearDown()
51     {
52         SugarTestHelper::tearDown();
53     }
54     
55     public function providerGetDurationMinutesOptions()
56     {
57         return array(
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>
64 EOHTML
65                 ),
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>
72 EOHTML
73                 ),
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>
80 EOHTML
81                 ),
82
83             array('DetailView','15'),
84         );
85     }
86     
87     /**
88      * @dataProvider providerGetDurationMinutesOptions
89      */
90         public function testGetDurationMinutesOptions(
91             $view,
92             $returnValue
93             )
94     {
95         $focus = new Call();
96         
97         $this->assertEquals(
98             getDurationMinutesOptions($focus,'','',$view),
99             $returnValue
100             );
101     }
102     
103     public function testGetDurationMinutesOptionsNonDefaultValue()
104     {
105         $focus = new Call();
106         $focus->duration_minutes = '30';
107         
108         $this->assertEquals(
109             getDurationMinutesOptions($focus,'','','DetailView'),
110             $focus->duration_minutes
111             );
112     }
113     
114     public function testGetDurationMinutesOptionsFromRequest()
115     {
116         $focus = new Call();
117         $_REQUEST['duration_minutes'] = '45';
118         
119         $this->assertEquals(
120             getDurationMinutesOptions($focus,'','','DetailView'),
121             $_REQUEST['duration_minutes']
122             );
123         
124         unset($_REQUEST['duration_minutes']);
125     }
126     
127     public function testGetDurationMinutesOptionsOtherValues()
128     {
129         $focus = new Call();
130         $focus->date_start = null;
131         $focus->duration_hours = null;
132         $focus->minutes_value_default = null;
133         
134         getDurationMinutesOptions($focus,'','','DetailView');
135         
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');
139     }
140     
141     public function providerGetReminderTime()
142     {
143         return array(
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>
152 EOHTML
153                 ),
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>
162 EOHTML
163                 ),
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>
172 EOHTML
173                 ),
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>
182 EOHTML
183                 ),
184
185             array('DetailView',''),
186         );
187     }
188     
189     /**
190      * @dataProvider providerGetReminderTime
191      */
192         public function testGetReminderTime($view,$returnValue)
193     {
194         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
195         $focus = new Call();
196         
197         $this->assertEquals( getReminderTime($focus,'','',$view),$returnValue);
198     }
199     
200     public function testGetReminderTimeNonDefaultValue()
201     {
202         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
203         $focus = new Call();
204         $focus->reminder_time = '600';
205         
206         $this->assertEquals(
207             getReminderTime($focus,'','','EditView'),
208             <<<EOHTML
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>
216 EOHTML
217             );
218     }
219     
220     public function testGetReminderTimeNonDefaultValueDetailView()
221     {
222         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
223
224         $focus = new Call();
225         $focus->reminder_time = '300';
226         
227         $this->assertEquals( getReminderTime($focus,'','','DetailView'),'5 minutes prior');
228     }
229     
230     public function testGetReminderTimeFromRequest()
231     {
232         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
233         $focus = new Call();
234         $_REQUEST['reminder_time'] = '900';
235         $_REQUEST['full_form'] = true;
236         
237         $this->assertEquals(
238             getReminderTime($focus,'','','EditView'),
239             <<<EOHTML
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>
247 EOHTML
248             );
249         
250         unset($_REQUEST['reminder_time']);
251         unset($_REQUEST['full_form']);
252     }
253     
254     public function testGetReminderTimeFromValue()
255     {
256         $this->markTestSkipped("getReminderTime deprecated as of 6.5.0");
257         $focus = new Call();
258         unset($focus->reminder_time);
259         
260         $this->assertEquals(
261             getReminderTime($focus,'','1800','EditView'),
262             <<<EOHTML
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>
270 EOHTML
271             );
272     }
273 }