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 Bug50768_02Test 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()
105 $this->markTestIncomplete("This test breaks others tests on 644 on CI. Disabling for sanity check");
107 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
109 $beanFiles = array();
110 require('include/modules.php');
111 $GLOBALS['beanList'] = $beanList;
112 $GLOBALS['beanFiles'] = $beanFiles;
114 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1);
116 $mbc = new ModuleBuilderController();
117 //Create the new Fields
118 $_REQUEST = $this->currencyFieldDef1;
119 $mbc->action_SaveField();
120 $_REQUEST = $this->currencyFieldDef2;
121 $mbc->action_SaveField();
125 public function tearDown()
127 /* $mbc = new ModuleBuilderController();
128 $this->currencyFieldDef1['name'] = 'c1_c';
129 $_REQUEST = $this->currencyFieldDef1;
130 $mbc->action_DeleteField();
131 $this->currencyFieldDef2['name'] = 'c2_c';
132 $_REQUEST = $this->currencyFieldDef2;
133 $mbc->action_DeleteField();
135 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
137 unset($GLOBALS['current_user']);
138 unset($GLOBALS['beanList']);
139 unset($GLOBALS['beanFiles']);
140 unset($GLOBALS['app_list_strings']);
146 * Test checks if currency_id field remains with currency_id type
149 public function testCurrencyIdType()
152 $bean = BeanFactory::getBean($this->targetModule);
155 $fieldDefs = $bean->field_defs;
156 if(isset($fieldDefs['currency_id']))
158 $cType = $fieldDefs['currency_id']['type'];
162 $this->assertEquals($cType, 'currency_id');
166 * Test checks if there is 1 currency_id field for 2 currency fields
169 public function testSettedCurrencyIdField()
172 $query = "SELECT * FROM fields_meta_data WHERE custom_module='Accounts' AND type='currency_id' AND deleted = 0";
173 $result = $GLOBALS['db']->query ( $query );
174 while ( $row = $GLOBALS['db']->fetchByAssoc ( $result ) ) {
177 $this->assertEquals($count, 1);