]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/ListView/ListViewDisplayTest.php
Release 6.2.4
[Github/sugarcrm.git] / tests / include / ListView / ListViewDisplayTest.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 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  
38 require_once 'include/ListView/ListViewDisplay.php';
39
40 class ListViewDisplayTest extends Sugar_PHPUnit_Framework_TestCase
41 {
42     public function setUp()
43     {
44         $this->_lvd = new ListViewDisplayMock();
45         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
46         $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
47     }
48
49     public function tearDown()
50     {
51         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
52         unset($GLOBALS['current_user']);
53         unset($GLOBALS['app_strings']);
54     }
55
56     public function testConstructor()
57     {
58         $this->assertInstanceOf('ListViewData',$this->_lvd->lvd);
59         $this->assertInternalType('array',$this->_lvd->searchColumns);
60     }
61
62     public function testShouldProcessWhenConfigSaveQueryIsNotSet()
63     {
64         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
65             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
66         }
67         $GLOBALS['sugar_config']['save_query'] = null;
68
69         $this->assertTrue($this->_lvd->shouldProcess('foo'));
70         $this->assertTrue($this->_lvd->should_process);
71
72         if ( isset($oldsavequery) ) {
73             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
74         }
75     }
76
77     public function testShouldProcessWhenConfigSaveQueryIsNotPopulateOnly()
78     {
79         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
80             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
81         }
82         $GLOBALS['sugar_config']['save_query'] = 'populate_always';
83
84         $this->assertTrue($this->_lvd->shouldProcess('foo'));
85         $this->assertTrue($this->_lvd->should_process);
86
87         if ( isset($oldsavequery) ) {
88             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
89         }
90     }
91
92     public function testShouldProcessWhenGlobalDisplayListViewIsTrue()
93     {
94         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
95             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
96         }
97         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
98         $GLOBALS['displayListView'] = true;
99
100         $this->assertTrue($this->_lvd->shouldProcess('foo'));
101         $this->assertTrue($this->_lvd->should_process);
102
103         if ( isset($oldsavequery) ) {
104             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
105         }
106     }
107
108     public function testShouldProcessWhenGlobalDisplayListViewIsFalseAndRequestClearQueryIsTrue()
109     {
110         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
111             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
112         }
113         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
114         $GLOBALS['displayListView'] = false;
115         $_REQUEST['clear_query'] = true;
116         $_REQUEST['module'] = 'foo';
117
118         $this->assertFalse($this->_lvd->shouldProcess('foo'));
119         $this->assertFalse($this->_lvd->should_process);
120
121         if ( isset($oldsavequery) ) {
122             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
123         }
124     }
125
126     public function testShouldProcessWhenGlobalDisplayListViewIsFalseAndRequestClearQueryIsFalseAndModulesDoNotEqual()
127     {
128         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
129             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
130         }
131         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
132         $GLOBALS['displayListView'] = false;
133         $_REQUEST['clear_query'] = false;
134         $_REQUEST['module'] = 'bar';
135
136         $this->assertTrue($this->_lvd->shouldProcess('foo'));
137         $this->assertTrue($this->_lvd->should_process);
138
139         if ( isset($oldsavequery) ) {
140             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
141         }
142     }
143
144     public function testShouldProcessWhenGlobalDisplayListViewIsFalseAndRequestClearQueryIsFalseAndModulesDoEqualAndQueryIsEmpty()
145     {
146         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
147             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
148         }
149         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
150         $GLOBALS['displayListView'] = false;
151         $_REQUEST['clear_query'] = false;
152         $_REQUEST['module'] = 'foo';
153         $_REQUEST['query'] = '';
154         $_SESSION['last_search_mod'] = '';
155
156         $this->assertFalse($this->_lvd->shouldProcess('foo'));
157         $this->assertFalse($this->_lvd->should_process);
158
159         if ( isset($oldsavequery) ) {
160             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
161         }
162     }
163
164     public function testShouldProcessWhenGlobalDisplayListViewIsFalseAndRequestClearQueryIsFalseAndModulesDoEqualAndQueryEqualsMsi()
165     {
166         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
167             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
168         }
169         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
170         $GLOBALS['displayListView'] = false;
171         $_REQUEST['clear_query'] = false;
172         $_REQUEST['module'] = 'foo';
173         $_REQUEST['query'] = 'MSI';
174         $_SESSION['last_search_mod'] = '';
175
176         $this->assertFalse($this->_lvd->shouldProcess('foo'));
177         $this->assertFalse($this->_lvd->should_process);
178
179         if ( isset($oldsavequery) ) {
180             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
181         }
182     }
183
184     public function testShouldProcessWhenGlobalDisplayListViewIsFalseAndRequestClearQueryIsFalseAndModulesDoNotEqualAndQueryDoesNotEqualsMsi()
185     {
186         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
187             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
188         }
189         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
190         $GLOBALS['displayListView'] = false;
191         $_REQUEST['clear_query'] = false;
192         $_REQUEST['module'] = 'foo';
193         $_REQUEST['query'] = 'xMSI';
194         $_SESSION['last_search_mod'] = '';
195
196         $this->assertTrue($this->_lvd->shouldProcess('foo'));
197         $this->assertTrue($this->_lvd->should_process);
198
199         if ( isset($oldsavequery) ) {
200             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
201         }
202     }
203
204     public function testShouldProcessWhenGlobalDisplayListViewIsFalseAndRequestClearQueryIsFalseAndModulesDoEqualAndLastSearchModEqualsModule()
205     {
206         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
207             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
208         }
209         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
210         $GLOBALS['displayListView'] = false;
211         $_REQUEST['clear_query'] = false;
212         $_REQUEST['module'] = 'foo';
213         $_REQUEST['query'] = '';
214         $_SESSION['last_search_mod'] = 'foo';
215
216         //C.L. Because of fix to 40186, the following two tests are now set to assertFalse
217         $this->assertFalse($this->_lvd->shouldProcess('foo'), 'Assert that ListViewDisplay->shouldProcess is false even if module is the same because no query was specified');
218         $this->assertFalse($this->_lvd->should_process, 'Assert that ListViewDisplay->shouldProcess class variable is false');
219
220         if ( isset($oldsavequery) ) {
221             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
222         }
223     }
224
225     public function testShouldProcessWhenGlobalDisplayListViewIsFalseAndRequestClearQueryIsFalseAndModulesDoEqualAndLastSearchModDoesNotEqualsModule()
226     {
227         if ( isset($GLOBALS['sugar_config']['save_query']) ) {
228             $oldsavequery = $GLOBALS['sugar_config']['save_query'];
229         }
230         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
231         $GLOBALS['displayListView'] = false;
232         $_REQUEST['clear_query'] = false;
233         $_REQUEST['module'] = 'foo';
234         $_REQUEST['query'] = '';
235         $_SESSION['last_search_mod'] = 'bar';
236
237         $this->assertFalse($this->_lvd->shouldProcess('foo'));
238         $this->assertFalse($this->_lvd->should_process);
239
240         if ( isset($oldsavequery) ) {
241             $GLOBALS['sugar_config']['save_query'] = $oldsavequery;
242         }
243     }
244
245     public function testProcess()
246     {
247         $data = array(
248             'data' => array(1,2,3),
249             'pageData' => array('bean' => array('moduleDir'=>'testmoduledir'))
250             );
251         $this->_lvd->process('foo',$data,'testmetestme');
252
253         $this->assertEquals(3,$this->_lvd->rowCount);
254         $this->assertEquals('testmoduledir2_TESTMETESTME_offset',$this->_lvd->moduleString);
255     }
256
257     public function testDisplayIfShouldNotProcess()
258     {
259         $this->_lvd->should_process = false;
260
261         $this->assertEmpty($this->_lvd->display());
262     }
263
264     public function testDisplayIfMultiSelectFalse()
265     {
266         $this->_lvd->should_process = true;
267         $this->_lvd->multiSelect = false;
268
269         $this->assertEmpty($this->_lvd->display());
270     }
271
272     public function testDisplayIfShowMassUpdateFormFalse()
273     {
274         $this->_lvd->should_process = true;
275         $this->_lvd->show_mass_update_form = false;
276
277         $this->assertEmpty($this->_lvd->display());
278     }
279
280     public function testDisplayIfShowMassUpdateFormTrueAndMultiSelectTrue()
281     {
282         $this->_lvd->should_process = true;
283         $this->_lvd->show_mass_update_form = true;
284         $this->_lvd->multiSelect = true;
285         $this->_lvd->multi_select_popup = true;
286         $this->_lvd->mass = $this->getMock('MassUpdate');
287         $this->_lvd->mass->expects($this->any())
288                          ->method('getDisplayMassUpdateForm')
289                          ->will($this->returnValue('foo'));
290         $this->_lvd->mass->expects($this->any())
291                          ->method('getMassUpdateFormHeader')
292                          ->will($this->returnValue('bar'));
293
294         $this->assertEquals('foobar',$this->_lvd->display());
295     }
296
297     public function testBuildSelectLink()
298     {
299         $output = $this->_lvd->buildSelectLink();
300
301         $this->assertContains("<a id='select_link' onclick='return select_overlib();'",$output);
302         $this->assertContains("sListView.check_all(document.MassUpdate, \"mass[]\", true, 0)",$output);
303         $this->assertContains("sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,0);",$output);
304     }
305
306     public function testBuildSelectLinkWithParameters()
307     {
308         $output = $this->_lvd->buildSelectLink('testtest',1,2);
309
310         $this->assertContains("<a id='testtest' onclick='return select_overlib();'",$output);
311         $this->assertContains("sListView.check_all(document.MassUpdate, \"mass[]\", true, 2)",$output);
312         $this->assertContains("sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,1);",$output);
313     }
314
315     public function testBuildSelectLinkWithPageTotalLessThanZero()
316     {
317         $output = $this->_lvd->buildSelectLink('testtest',1,-1);
318
319         $this->assertContains("<a id='testtest' onclick='return select_overlib();'",$output);
320         $this->assertContains("sListView.check_all(document.MassUpdate, \"mass[]\", true, 1)",$output);
321         $this->assertContains("sListView.check_entire_list(document.MassUpdate, \"mass[]\",true,1);",$output);
322     }
323
324     public function testBuildExportLink()
325     {
326         $this->_lvd->seed = new stdClass;
327         $this->_lvd->seed->module_dir = 'testtest';
328         $output = $this->_lvd->buildExportLink();
329
330         $this->assertContains("return sListView.send_form(true, 'testtest', 'index.php?entryPoint=export',",$output);
331     }
332
333     public function testBuildMassUpdateLink()
334     {
335         $output = $this->_lvd->buildMassUpdateLink();
336
337         $this->assertContains("<a href='#massupdate_form'",$output);
338     }
339
340     public function testComposeEmailIfFieldDefsNotAnArray()
341     {
342         $this->_lvd->seed = new stdClass;
343         $this->_lvd->seed->field_defs = false;
344         
345         $this->assertEmpty($this->_lvd->buildComposeEmailLink(0));
346     }
347
348     public function testComposeEmailIfFieldDefsAreAnEmptyArray()
349     {
350         $this->_lvd->seed = new stdClass;
351         $this->_lvd->seed->field_defs = array();
352
353         $this->assertEmpty($this->_lvd->buildComposeEmailLink(0));
354     }
355
356     public function testComposeEmailIfFieldDefsDoNotHaveAnEmailAddressesRelationship()
357     {
358         $this->_lvd->seed = new stdClass;
359         $this->_lvd->seed->object_name = 'foobar';
360         $this->_lvd->seed->field_defs = array(
361             'field1' => array(
362                 'type' => 'text',
363                 ),
364             );
365
366         $this->assertEmpty($this->_lvd->buildComposeEmailLink(0));
367     }
368
369     public function testComposeEmailIfFieldDefsIfUsingSugarEmailClient()
370     {
371         $this->_lvd->seed = new stdClass;
372         $this->_lvd->seed->object_name = 'foobar';
373         $this->_lvd->seed->module_dir = 'foobarfoobar';
374         $this->_lvd->seed->field_defs = array(
375             'field1' => array(
376                 'type' => 'link',
377                 'relationship' => 'foobar_emailaddresses',
378                 ),
379             );
380         $GLOBALS['dictionary']['foobar']['relationships']['foobar_emailaddresses']['rhs_module'] = 'EmailAddresses';
381         $GLOBALS['current_user']->setPreference('email_link_type','sugar');
382
383         $output = $this->_lvd->buildComposeEmailLink(5);
384
385         $this->assertContains(', \'foobarfoobar\', \'5\', ',$output);
386
387         unset($GLOBALS['dictionary']['foobar']);
388     }
389
390     public function testComposeEmailIfFieldDefsIfUsingExternalEmailClient()
391     {
392         $this->_lvd->seed = new stdClass;
393         $this->_lvd->seed->object_name = 'foobar';
394         $this->_lvd->seed->module_dir = 'foobarfoobar';
395         $this->_lvd->seed->field_defs = array(
396             'field1' => array(
397                 'type' => 'link',
398                 'relationship' => 'foobar_emailaddresses',
399                 ),
400             );
401         $_REQUEST['module'] = 'foo';
402         
403         $GLOBALS['dictionary']['foobar']['relationships']['foobar_emailaddresses']['rhs_module'] = 'EmailAddresses';
404         $GLOBALS['current_user']->setPreference('email_link_type','mailto');
405
406         $output = $this->_lvd->buildComposeEmailLink(5);
407
408         $this->assertContains('sListView.use_external_mail_client',$output);
409
410         unset($GLOBALS['dictionary']['foobar']);
411         unset($_REQUEST['module']);
412     }
413
414     public function testBuildDeleteLink()
415     {
416         $output = $this->_lvd->buildDeleteLink();
417
418         $this->assertContains("return sListView.send_mass_update",$output);
419     }
420
421     public function testBuildSelectedObjectsSpan()
422     {
423         $output = $this->_lvd->buildSelectedObjectsSpan(1,1);
424
425         $this->assertContains("<input  style='border: 0px; background: transparent; font-size: inherit; color: inherit' type='text' id='selectCountTop' readonly name='selectCount[]' value='1' />",$output);
426     }
427
428     public function testBuildMergeDuplicatesLinkWithNoAccess()
429     {
430         $this->markTestIncomplete('This test has not been implemented yet.');
431     }
432
433     public function testBuildMergeDuplicatesLinkWhenModuleDoesNotHaveItEnabled()
434     {
435         $this->_lvd->seed = new stdClass;
436         $this->_lvd->seed->object_name = 'foobar';
437         $this->_lvd->seed->module_dir = 'foobarfoobar';
438         $GLOBALS['dictionary']['foobar']['duplicate_merge'] = false;
439         $GLOBALS['current_user']->is_admin = 1;
440
441         $this->assertEmpty($this->_lvd->buildMergeDuplicatesLink());
442     }
443
444     public function testBuildMergeDuplicatesLink()
445     {
446         $this->_lvd->seed = new stdClass;
447         $this->_lvd->seed->object_name = 'foobar';
448         $this->_lvd->seed->module_dir = 'foobarfoobar';
449         $GLOBALS['dictionary']['foobar']['duplicate_merge'] = true;
450         $GLOBALS['current_user']->is_admin = 1;
451
452         $output = $this->_lvd->buildMergeDuplicatesLink();
453
454         $this->assertContains("\"foobarfoobar\",\"\");}",$output);
455     }
456
457     public function testBuildMergeDuplicatesLinkBuildsReturnString()
458     {
459         $this->_lvd->seed = new stdClass;
460         $this->_lvd->seed->object_name = 'foobar';
461         $this->_lvd->seed->module_dir = 'foobarfoobar';
462         $GLOBALS['dictionary']['foobar']['duplicate_merge'] = true;
463         $GLOBALS['current_user']->is_admin = 1;
464         $_REQUEST['module'] = 'foo';
465         $_REQUEST['action'] = 'bar';
466         $_REQUEST['record'] = '1';
467
468         $output = $this->_lvd->buildMergeDuplicatesLink();
469
470         $this->assertContains("\"foobarfoobar\",\"&return_module=foo&return_action=bar&return_id=1\");}",$output);
471     }
472     public function testBuildMergeLinkWhenUserDisabledMailMerge()
473     {
474         $this->_lvd->seed = new stdClass;
475         $this->_lvd->seed->module_dir = 'foobarfoobar';
476         $GLOBALS['current_user']->setPreference('mailmerge_on','off');
477
478         $this->assertEmpty($this->_lvd->buildMergeLink());
479     }
480
481     public function testBuildMergeLinkWhenSystemDisabledMailMerge()
482     {
483         $this->_lvd->seed = new stdClass;
484         $this->_lvd->seed->module_dir = 'foobarfoobar';
485
486         $GLOBALS['current_user']->setPreference('mailmerge_on','on');
487
488         $settings_cache = sugar_cache_retrieve('admin_settings_cache');
489         if ( empty($settings_cache) ) {
490             $settings_cache = array();
491         }
492         $settings_cache['system_mailmerge_on'] = false;
493         sugar_cache_put('admin_settings_cache',$settings_cache);
494
495         $this->assertEmpty($this->_lvd->buildMergeLink());
496
497         sugar_cache_clear('admin_settings_cache');
498     }
499
500     public function testBuildMergeLinkWhenModuleNotInModulesArray()
501     {
502         $this->_lvd->seed = new stdClass;
503         $this->_lvd->seed->module_dir = 'foobarfoobar';
504
505         $GLOBALS['current_user']->setPreference('mailmerge_on','on');
506
507         $settings_cache = sugar_cache_retrieve('admin_settings_cache');
508         if ( empty($settings_cache) ) {
509             $settings_cache = array();
510         }
511         $settings_cache['system_mailmerge_on'] = true;
512         sugar_cache_put('admin_settings_cache',$settings_cache);
513
514         $this->assertEmpty($this->_lvd->buildMergeLink(array('foobar' => 'foobar')));
515
516         sugar_cache_clear('admin_settings_cache');
517     }
518
519     public function testBuildMergeLink()
520     {
521         $this->_lvd->seed = new stdClass;
522         $this->_lvd->seed->module_dir = 'foobarfoobar';
523
524         $GLOBALS['current_user']->setPreference('mailmerge_on','on');
525
526         $settings_cache = sugar_cache_retrieve('admin_settings_cache');
527         if ( empty($settings_cache) ) {
528             $settings_cache = array();
529         }
530         $settings_cache['system_mailmerge_on'] = true;
531         sugar_cache_put('admin_settings_cache',$settings_cache);
532
533         $output = $this->_lvd->buildMergeLink(array('foobarfoobar' => 'foobarfoobar'));
534         $this->assertContains("index.php?action=index&module=MailMerge&entire=true",$output);
535
536         sugar_cache_clear('admin_settings_cache');
537     }
538
539     public function testBuildTargetLink()
540     {
541         $_POST['module'] = 'foobar';
542         $this->_lvd->seed = new stdClass;
543         $this->_lvd->seed->module_dir = 'foobarfoobar';
544
545         $output = $this->_lvd->buildTargetList();
546
547         $this->assertContains("input.setAttribute ( 'name' , 'module' );                            input.setAttribute ( 'value' , 'foobarfoobar' );",$output);
548         $this->assertContains("input.setAttribute ( 'name' , 'current_query_by_page' );                     input.setAttribute ( 'value', '".base64_encode(serialize($_REQUEST))."' );",$output);
549     }
550
551     public function testDisplayEndWhenNotShowingMassUpdateForm()
552     {
553         $this->_lvd->show_mass_update_form = false;
554
555         $this->assertEmpty($this->_lvd->displayEnd());
556     }
557
558     public function testDisplayEndWhenShowingMassUpdateForm()
559     {
560         $this->_lvd->show_mass_update_form = true;
561         $this->_lvd->mass = $this->getMock('MassUpdate');
562         $this->_lvd->mass->expects($this->any())
563                          ->method('getMassUpdateForm')
564                          ->will($this->returnValue('foo'));
565         $this->_lvd->mass->expects($this->any())
566                          ->method('endMassUpdateForm')
567                          ->will($this->returnValue('bar'));
568
569         $this->assertEquals('foobar',$this->_lvd->displayEnd());
570     }
571
572     public function testGetMultiSelectData()
573     {
574         $this->_lvd->moduleString = 'foobar';
575
576         $output = $this->_lvd->getMultiSelectData();
577
578         $this->assertEquals($output, "<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n".
579                                 "<textarea style='display: none' name='uid'></textarea>\n" .
580                                 "<input type='hidden' name='select_entire_list' value='0'>\n".
581                                 "<input type='hidden' name='foobar' value='0'>\n".
582                 "<input type='hidden' name='show_plus' value=''>\n",$output);
583     }
584
585     public function testGetMultiSelectDataWithRequestParameterUidSet()
586     {
587         $this->_lvd->moduleString = 'foobar';
588         $_REQUEST['uid'] = '1234';
589
590         $output = $this->_lvd->getMultiSelectData();
591
592         $this->assertEquals("<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n".
593                                 "<textarea style='display: none' name='uid'>1234</textarea>\n" .
594                                 "<input type='hidden' name='select_entire_list' value='0'>\n".
595                                 "<input type='hidden' name='foobar' value='0'>\n" .
596                 "<input type='hidden' name='show_plus' value=''>\n",$output);        
597     }
598
599     public function testGetMultiSelectDataWithRequestParameterSelectEntireListSet()
600     {
601         $this->_lvd->moduleString = 'foobar';
602         $_REQUEST['select_entire_list'] = '1234';
603
604         $output = $this->_lvd->getMultiSelectData();
605
606         $this->assertEquals("<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n".
607                                 "<textarea style='display: none' name='uid'></textarea>\n" .
608                                 "<input type='hidden' name='select_entire_list' value='1234'>\n".
609                                 "<input type='hidden' name='foobar' value='0'>\n" .
610                 "<input type='hidden' name='show_plus' value=''>\n",$output);        
611     }
612
613     public function testGetMultiSelectDataWithRequestParameterMassupdateSet()
614     {
615         $this->_lvd->moduleString = 'foobar';
616         $_REQUEST['uid'] = '1234';
617         $_REQUEST['select_entire_list'] = '5678';
618         $_REQUEST['massupdate'] = 'true';
619
620         $output = $this->_lvd->getMultiSelectData();
621
622         $this->assertEquals("<script>YAHOO.util.Event.addListener(window, \"load\", sListView.check_boxes);</script>\n".
623                                 "<textarea style='display: none' name='uid'></textarea>\n" .
624                                 "<input type='hidden' name='select_entire_list' value='0'>\n".
625                                 "<input type='hidden' name='foobar' value='0'>\n".
626                 "<input type='hidden' name='show_plus' value=''>\n",$output);        
627     }
628 }
629
630 class ListViewDisplayMock extends ListViewDisplay
631 {
632     public function buildExportLink()
633     {
634         return parent::buildExportLink();
635     }
636
637     public function buildMassUpdateLink()
638     {
639         return parent::buildMassUpdateLink();
640     }
641
642     public function buildComposeEmailLink($totalCount)
643     {
644         return parent::buildComposeEmailLink($totalCount);
645     }
646
647     public function buildDeleteLink()
648     {
649         return parent::buildDeleteLink();
650     }
651
652     public function buildMergeDuplicatesLink()
653     {
654         return parent::buildMergeDuplicatesLink();
655     }
656
657     public function buildMergeLink(array $modules_array = null)
658     {
659         return parent::buildMergeLink($modules_array);
660     }
661
662     public function buildTargetList()
663     {
664         return parent::buildTargetList();
665     }
666 }