]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/Popup/Bug36329Test.php
Added unit tests.
[Github/sugarcrm.git] / tests / include / Popup / Bug36329Test.php
1 <?php 
2 require_once('include/OutboundEmail/OutboundEmail.php');
3
4 /**
5  * @group bug23140
6  */
7 class Bug36329Test extends Sugar_PHPUnit_Framework_TestCase
8 {
9         var $save_query;
10         var $current_language;
11
12         public function setUp() 
13         {
14                 global $sugar_config;
15                 $this->save_query = isset($sugar_config['save_query']) ? true : false;
16                 $this->current_language = $GLOBALS['current_language'];
17                 
18                 global $current_user;
19                 $current_user = new User();
20                 $current_user->retrieve('1');
21                 
22                 global $mod_strings, $app_strings;
23                 $mod_strings = return_module_language('en_us', 'Accounts');
24                 $app_strings = return_application_language('en_us');
25                 
26                 $beanList = array();
27                 $beanFiles = array();
28                 require('include/modules.php');
29                 $GLOBALS['beanList'] = $beanList;
30                 $GLOBALS['beanFiles'] = $beanFiles;
31
32                 require('sugar_version.php');
33                 $GLOBALS['sugar_version'] = $sugar_version;
34         }
35         
36         public function tearDown() 
37         {
38                 global $sugar_config;
39                 
40                 if(!$this->save_query) {
41                    unset($sugar_config['save_query']);
42                 }
43                 
44                 $GLOBALS['current_language'] = $this->current_language;
45                 unset($GLOBALS['mod_strings']);
46                 unset($GLOBALS['app_strings']);
47                 unset($GLOBALS['beanList']);
48                 unset($GLOBALS['beanFiles']);
49         }
50
51     public function test_populate_only_no_query()
52     {
53         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
54         $_REQUEST['module'] = 'Accounts';
55         $_REQUEST['action'] = 'Popup';
56         $_REQUEST['mode'] = 'single';
57         $_REQUEST['create'] = 'true';
58         $_REQUEST['metadata'] = 'undefined';
59         require_once('include/MVC/View/SugarView.php');
60         require_once('include/MVC/View/views/view.popup.php');
61         require_once('include/utils/layout_utils.php');
62         $popup = new ViewPopup();
63         $popup->module = 'Accounts';
64         require_once('modules/Accounts/Account.php');
65         $popup->bean = new account();
66         ob_start();
67         $popup->display();
68         $ob_contents = ob_get_contents();
69                 ob_end_clean();
70         $found_text = preg_match('/Perform a search using the search form above/', $ob_contents) ? true : false;
71         $this->assertTrue($found_text);
72     }
73     
74     
75     public function test_populate_only_with_query()
76     {
77         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
78         global $app_strings;
79         $_REQUEST['module'] = 'Accounts';
80         $_REQUEST['action'] = 'Popup';
81         $_REQUEST['mode'] = 'single';
82         $_REQUEST['create'] = 'true';
83         $_REQUEST['metadata'] = 'undefined';
84         $_REQUEST['name_advanced'] = 'Test';
85         $_REQUEST['query'] = 'true';
86         require_once('include/MVC/View/SugarView.php');
87         require_once('include/MVC/View/views/view.popup.php');
88         require_once('include/utils/layout_utils.php');
89         $popup = new ViewPopup();
90         $popup->module = 'Accounts';
91         require_once('modules/Accounts/Account.php');
92         $popup->bean = new account();
93         ob_start();
94         $popup->display();
95         $ob_contents = ob_get_contents();
96                 ob_end_clean();
97         $found_text = preg_match('/Perform a search using the search form above/', $ob_contents) ? true : false;
98         $this->assertFalse($found_text);
99     }       
100 }