]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/ModuleBuilder/Bug52063Test.php
Release 6.5.5
[Github/sugarcrm.git] / tests / modules / ModuleBuilder / Bug52063Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2012 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 'modules/DynamicFields/templates/Fields/TemplateCurrency.php';
39 require_once("modules/ModuleBuilder/controller.php");
40
41 /**
42  * Bug #52063
43  * Failed to deploy if the new package with customized Currency field
44  *
45  * @ticket 52063
46  */
47
48 class Bug52063Test extends Sugar_PHPUnit_Framework_TestCase
49 {
50     protected $targetModule = "Accounts";
51     protected $currencyFieldDef1 = array(
52         "action" => "saveField",
53         "comments" => "",
54         "default" => "",
55         "dependency" => "",
56         "dependency_display" => "",
57         "duplicate_merge" => "0",
58         "enforced" => "false",
59         "formula" => "",
60         "formula_display" => "",
61         "help" => "",
62         "importable" => "true",
63         "is_update" => "true",
64         "labelValue" => "test_cur_c1",
65         "label" => "LBL_TEST_CUR_1",
66         "new_dropdown" => "",
67         "reportableCheckbox" => "1",
68         "reportable" => "1",
69         "to_pdf" => "true",
70         "type" => "currency",
71         "name" => "c1",
72         "module" => "ModuleBuilder",
73         "view_module" => "Accounts",
74     );
75
76     protected $currencyFieldDef2 = array(
77         "action" => "saveField",
78         "comments" => "",
79         "default" => "",
80         "dependency" => "",
81         "dependency_display" => "",
82         "duplicate_merge" => "0",
83         "enforced" => "false",
84         "formula" => "",
85         "formula_display" => "",
86         "help" => "",
87         "importable" => "true",
88         "is_update" => "true",
89         "labelValue" => "test_cur_c2",
90         "label" => "LBL_TEST_CUR_2",
91         "new_dropdown" => "",
92         "reportableCheckbox" => "1",
93         "reportable" => "1",
94         "to_pdf" => "true",
95         "type" => "currency",
96         "name" => "c2",
97         "module" => "ModuleBuilder",
98         "view_module" => "Accounts",
99     );
100
101     public function setUp()
102     {
103         $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
104         $beanList = array();
105         $beanFiles = array();
106         require('include/modules.php');
107         $GLOBALS['beanList'] = $beanList;
108         $GLOBALS['beanFiles'] = $beanFiles;
109
110         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1);
111
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();
118
119     }
120
121     public function tearDown()
122     {
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();
130
131         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
132
133         unset($GLOBALS['current_user']);
134         unset($GLOBALS['beanList']);
135         unset($GLOBALS['beanFiles']);
136         unset($GLOBALS['app_list_strings']);
137         $_REQUEST = array();
138         SugarCache::$isCacheReset = false;
139         SugarTestHelper::tearDown();
140     }
141
142     /**
143      * Test checks if currency_id field remains with currency_id type
144      * @group 52063
145      */
146     public function testCurrencyIdDbType()
147     {
148         $cType = '';
149         $bean = BeanFactory::getBean($this->targetModule);
150         if(!empty($bean))
151         {
152             $fieldDefs = $bean->field_defs;
153             if(isset($fieldDefs['currency_id']))
154             {
155                 $cType = $fieldDefs['currency_id']['dbType'];
156             }
157         }
158
159         $this->assertEquals($cType, 'id');
160     }
161 }