2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
38 /*********************************************************************************
39 * SugarCRM Community Edition is a customer relationship management program developed by
40 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
42 * This program is free software; you can redistribute it and/or modify it under
43 * the terms of the GNU Affero General Public License version 3 as published by the
44 * Free Software Foundation with the addition of the following permission added
45 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
46 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
47 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
49 * This program is distributed in the hope that it will be useful, but WITHOUT
50 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
51 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
54 * You should have received a copy of the GNU Affero General Public License along with
55 * this program; if not, see http://www.gnu.org/licenses or write to the Free
56 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
59 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
60 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
62 * The interactive user interfaces in modified source and object code versions
63 * of this program must display Appropriate Legal Notices, as required under
64 * Section 5 of the GNU Affero General Public License version 3.
66 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
67 * these Appropriate Legal Notices must retain the display of the "Powered by
68 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
69 * technical reasons, the Appropriate Legal Notices must display the words
70 * "Powered by SugarCRM".
71 ********************************************************************************/
74 require_once "modules/Leads/Lead.php";
75 require_once "include/Popups/PopupSmarty.php";
77 class Bug43452Test extends Sugar_PHPUnit_Framework_TestCase
79 public function setUp()
81 $GLOBALS['app_strings'] = return_application_language($GLOBALS['current_language']);
84 public function tearDown()
86 unset($GLOBALS['app_strings']);
92 public function testGenerateSearchWhereWithUnsetBool()
94 // Looking for a NON Converted Lead named "Fabio".
95 // Without changes, PopupSmarty return a bad query, with AND and OR at the same level.
96 // With this fix we get parenthesis:
97 // 1) From SearchForm2->generateSearchWhere, in case of 'bool' (they surround "converted = '0' or converted IS NULL")
98 // 2) From PopupSmarty->_get_where_clause, when items of where's array are imploded.
100 $tGoodWhere = "( leads.first_name like 'Fabio%' and ( leads.converted = '0' OR leads.converted IS NULL ) )";
102 $_searchFields['Leads'] = array ('first_name'=> array('value' => 'Fabio', 'query_type'=>'default'),
103 'converted'=> array('value' => '0', 'query_type'=>'default'),
105 // provides $searchdefs['Leads']
106 require "modules/Leads/metadata/searchdefs.php";
108 $bean = $this->getMock('Lead');
109 $popup = new PopupSmarty($bean, "Leads");
110 $popup->searchForm->searchdefs = $searchdefs['Leads'];
111 $popup->searchForm->searchFields = $_searchFields['Leads'];
112 $tWhere = $popup->_get_where_clause();
114 $this->assertEquals($tGoodWhere, $tWhere);