2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 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 * Failed to deploy if the new package with customized Currency field
48 class Bug52063Test extends Sugar_PHPUnit_Framework_TestCase
50 protected $targetModule = "Accounts";
51 protected $currencyFieldDef1 = array(
52 "action" => "saveField",
56 "dependency_display" => "",
57 "duplicate_merge" => "0",
58 "enforced" => "false",
60 "formula_display" => "",
62 "importable" => "true",
63 "is_update" => "true",
64 "labelValue" => "test_cur_c1",
65 "label" => "LBL_TEST_CUR_1",
67 "reportableCheckbox" => "1",
72 "module" => "ModuleBuilder",
73 "view_module" => "Accounts",
76 protected $currencyFieldDef2 = array(
77 "action" => "saveField",
81 "dependency_display" => "",
82 "duplicate_merge" => "0",
83 "enforced" => "false",
85 "formula_display" => "",
87 "importable" => "true",
88 "is_update" => "true",
89 "labelValue" => "test_cur_c2",
90 "label" => "LBL_TEST_CUR_2",
92 "reportableCheckbox" => "1",
97 "module" => "ModuleBuilder",
98 "view_module" => "Accounts",
101 public function setUp()
103 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
105 $beanFiles = array();
106 require('include/modules.php');
107 $GLOBALS['beanList'] = $beanList;
108 $GLOBALS['beanFiles'] = $beanFiles;
110 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1);
112 $mbc = new ModuleBuilderController();
113 //Create the new Fields
114 $_REQUEST = $this->currencyFieldDef1;
115 $mbc->action_SaveField();
116 $_REQUEST = $this->currencyFieldDef2;
117 $mbc->action_SaveField();
121 public function tearDown()
123 $mbc = new ModuleBuilderController();
124 $this->currencyFieldDef1['name'] = 'c1_c';
125 $_REQUEST = $this->currencyFieldDef1;
126 $mbc->action_DeleteField();
127 $this->currencyFieldDef2['name'] = 'c2_c';
128 $_REQUEST = $this->currencyFieldDef2;
129 $mbc->action_DeleteField();
131 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
133 unset($GLOBALS['current_user']);
134 unset($GLOBALS['beanList']);
135 unset($GLOBALS['beanFiles']);
136 unset($GLOBALS['app_list_strings']);
138 SugarCache::$isCacheReset = false;
139 SugarTestHelper::tearDown();
143 * Test checks if currency_id field remains with currency_id type
146 public function testCurrencyIdDbType()
149 $bean = BeanFactory::getBean($this->targetModule);
152 $fieldDefs = $bean->field_defs;
153 if(isset($fieldDefs['currency_id']))
155 $cType = $fieldDefs['currency_id']['dbType'];
159 $this->assertEquals($cType, 'id');