]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/Popup/Bug36329Test.php
Release 6.2.3
[Github/sugarcrm.git] / tests / include / Popup / Bug36329Test.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/OutboundEmail/OutboundEmail.php');
39
40 /**
41  * @ticket 23140
42  */
43 class Bug36329Test extends Sugar_PHPUnit_Framework_OutputTestCase
44 {
45         var $save_query;
46         var $current_language;
47
48         public function setUp()
49         {
50                 global $sugar_config;
51                 $this->save_query = isset($sugar_config['save_query']) ? true : false;
52                 $this->current_language = $GLOBALS['current_language'];
53
54                 global $current_user;
55                 $current_user = new User();
56                 $current_user->retrieve('1');
57
58                 global $mod_strings, $app_strings;
59                 $mod_strings = return_module_language('en_us', 'Accounts');
60                 $app_strings = return_application_language('en_us');
61
62                 $beanList = array();
63                 $beanFiles = array();
64                 require('include/modules.php');
65                 $GLOBALS['beanList'] = $beanList;
66                 $GLOBALS['beanFiles'] = $beanFiles;
67
68                 require('sugar_version.php');
69                 $GLOBALS['sugar_version'] = $sugar_version;
70         }
71
72         public function tearDown()
73         {
74             global $sugar_config;
75                 if(!$this->save_query) {
76                    unset($sugar_config['save_query']);
77                 }
78
79                 $GLOBALS['current_language'] = $this->current_language;
80                 //unset($GLOBALS['mod_strings']);
81                 //unset($GLOBALS['app_strings']);
82                 //unset($GLOBALS['beanList']);
83                 //unset($GLOBALS['beanFiles']);
84         }
85
86     public function test_populate_only_no_query()
87     {
88         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
89         $_REQUEST['module'] = 'Accounts';
90         $_REQUEST['action'] = 'Popup';
91         $_REQUEST['mode'] = 'single';
92         $_REQUEST['create'] = 'true';
93         $_REQUEST['metadata'] = 'undefined';
94         require_once('include/MVC/View/SugarView.php');
95         require_once('include/MVC/View/views/view.popup.php');
96         require_once('include/utils/layout_utils.php');
97         $popup = new ViewPopup();
98         $popup->module = 'Accounts';
99         require_once('modules/Accounts/Account.php');
100         $popup->bean = new account();
101         $this->expectOutputRegex("/Perform a search using the search form above/");
102         $popup->display();
103     }
104
105
106     public function test_populate_only_with_query()
107     {
108         $GLOBALS['sugar_config']['save_query'] = 'populate_only';
109         global $app_strings;
110         $_REQUEST['module'] = 'Accounts';
111         $_REQUEST['action'] = 'Popup';
112         $_REQUEST['mode'] = 'single';
113         $_REQUEST['create'] = 'true';
114         $_REQUEST['metadata'] = 'undefined';
115         $_REQUEST['name_advanced'] = 'Test';
116         $_REQUEST['query'] = 'true';
117         require_once('include/MVC/View/SugarView.php');
118         require_once('include/MVC/View/views/view.popup.php');
119         require_once('include/utils/layout_utils.php');
120         $popup = new ViewPopup();
121         $popup->module = 'Accounts';
122         require_once('modules/Accounts/Account.php');
123         $popup->bean = new account();
124         // Negative regexp
125         $this->expectOutputNotRegex('/Perform a search using the search form above/');
126         $popup->display();
127     }
128 }