]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/SearchForm/SugarSpotTest.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / SearchForm / SugarSpotTest.php
1 <?php
2 require_once 'include/SearchForm/SugarSpot.php';
3
4 class SugarSpotTest extends Sugar_PHPUnit_Framework_TestCase
5 {
6     public function setUp()
7     {
8         $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']); 
9     }
10     
11     public function tearDown()
12     {
13         unset($GLOBALS['app_strings']);
14     }
15     
16     /**
17      * @ticket 41236
18      */
19     public function testSearchGrabsModuleDisplayName() 
20     {
21         $langpack = new SugarTestLangPackCreator();
22         $langpack->setAppListString('moduleList',array('Foo'=>'Bar'));
23         $langpack->save();
24         
25         $result = array(
26             'Foo' => array(
27                 'data' => array(
28                     array(
29                         'ID' => '1',
30                         'NAME' => 'recordname',
31                         ),
32                     ),
33                 'pageData' => array(
34                     'offsets' => array(
35                         'total' => 1,
36                         'next' => 0,
37                         ),
38                     'bean' => array(
39                         'moduleDir' => 'Foo',
40                         ),
41                     ),
42                 ),
43             );
44         
45         $sugarSpot = $this->getMock('SugarSpot', array('_performSearch'));
46         $sugarSpot->expects($this->any())
47             ->method('_performSearch')
48             ->will($this->returnValue($result));
49             
50         $returnValue = $sugarSpot->searchAndDisplay('','');
51         
52         $this->assertNotContains('<div id="SpotResults"><div>Foo </div>',$returnValue);
53         $this->assertContains('<div id="SpotResults"><div>Bar </div>',$returnValue);
54     }
55 }