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 require_once 'modules/DynamicFields/templates/Fields/TemplateCurrency.php';
39 require_once("modules/ModuleBuilder/controller.php");
43 * in Studio once set the visibility function for currency field will miss the currency_Id
45 * @author asokol@sugarcrm.com
49 class Bug50768Test extends Sugar_PHPUnit_Framework_TestCase
51 protected $targetModule = "Accounts";
52 protected $currencyFieldDef1 = array(
53 "action" => "saveField",
57 "dependency_display" => "",
58 "duplicate_merge" => "0",
59 "enforced" => "false",
61 "formula_display" => "",
63 "importable" => "true",
64 "is_update" => "true",
65 "labelValue" => "test_cur_c1",
66 "label" => "LBL_TEST_CUR_1",
68 "reportableCheckbox" => "1",
73 "module" => "ModuleBuilder",
74 "view_module" => "Accounts",
77 protected $currencyFieldDef2 = array(
78 "action" => "saveField",
82 "dependency_display" => "",
83 "duplicate_merge" => "0",
84 "enforced" => "false",
86 "formula_display" => "",
88 "importable" => "true",
89 "is_update" => "true",
90 "labelValue" => "test_cur_c2",
91 "label" => "LBL_TEST_CUR_2",
93 "reportableCheckbox" => "1",
98 "module" => "ModuleBuilder",
99 "view_module" => "Accounts",
102 public function setUp()
104 $this->markTestIncomplete("This test breaks others tests on 644 on CI. Disabling for sanity check");
105 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
107 $beanFiles = array();
108 require('include/modules.php');
109 $GLOBALS['beanList'] = $beanList;
110 $GLOBALS['beanFiles'] = $beanFiles;
112 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1);
116 public function tearDown()
118 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
120 /* unset($GLOBALS['current_user']);
121 unset($GLOBALS['beanList']);
122 unset($GLOBALS['beanFiles']);
123 unset($GLOBALS['app_list_strings']);
129 * Test checks if currency_id field was deleted with the lasr currency field
132 public function testSettedCurrencyIdField()
134 $mbc = new ModuleBuilderController();
135 //Create the new Fields
136 $_REQUEST = $this->currencyFieldDef1;
137 $mbc->action_SaveField();
138 $_REQUEST = $this->currencyFieldDef2;
139 $mbc->action_SaveField();
141 $this->currencyFieldDef1['name'] = 'c1_c';
142 $_REQUEST = $this->currencyFieldDef1;
143 // $mbc->action_DeleteField();
144 $this->currencyFieldDef2['name'] = 'c2_c';
145 $_REQUEST = $this->currencyFieldDef2;
146 // $mbc->action_DeleteField();
149 $query = "SELECT * FROM fields_meta_data WHERE custom_module='Accounts' AND type='currency_id' AND deleted = 0";
150 $result = $GLOBALS['db']->query ( $query );
151 while ( $row = $GLOBALS['db']->fetchByAssoc ( $result ) ) {
154 $this->assertEquals($count, 0);