]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/ModuleBuilder/Bug50768_02Test.php
Release 6.5.10
[Github/sugarcrm.git] / tests / modules / ModuleBuilder / Bug50768_02Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2013 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 #50768
43  * in Studio once set the visibility function for currency field will miss the currency_Id
44  *
45  * @author asokol@sugarcrm.com
46  * @ticket 50768
47  */
48
49 class Bug50768_02Test extends Sugar_PHPUnit_Framework_TestCase
50 {
51     protected $targetModule = "Accounts";
52     protected $currencyFieldDef1 = array(
53         "action" => "saveField",
54         "comments" => "",
55         "default" => "",
56         "dependency" => "",
57         "dependency_display" => "",
58         "duplicate_merge" => "0",
59         "enforced" => "false",
60         "formula" => "",
61         "formula_display" => "",
62         "help" => "",
63         "importable" => "true",
64         "is_update" => "true",
65         "labelValue" => "test_cur_c1",
66         "label" => "LBL_TEST_CUR_1",
67         "new_dropdown" => "",
68         "reportableCheckbox" => "1",
69         "reportable" => "1",
70         "to_pdf" => "true",
71         "type" => "currency",
72         "name" => "c1",
73         "module" => "ModuleBuilder",
74         "view_module" => "Accounts",
75     );
76
77     protected $currencyFieldDef2 = array(
78         "action" => "saveField",
79         "comments" => "",
80         "default" => "",
81         "dependency" => "",
82         "dependency_display" => "",
83         "duplicate_merge" => "0",
84         "enforced" => "false",
85         "formula" => "",
86         "formula_display" => "",
87         "help" => "",
88         "importable" => "true",
89         "is_update" => "true",
90         "labelValue" => "test_cur_c2",
91         "label" => "LBL_TEST_CUR_2",
92         "new_dropdown" => "",
93         "reportableCheckbox" => "1",
94         "reportable" => "1",
95         "to_pdf" => "true",
96         "type" => "currency",
97         "name" => "c2",
98         "module" => "ModuleBuilder",
99         "view_module" => "Accounts",
100     );
101
102     public function setUp()
103     {
104
105         $this->markTestIncomplete("This test breaks others tests on 644 on CI.  Disabling for sanity check");
106
107         $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
108         $beanList = array();
109         $beanFiles = array();
110         require('include/modules.php');
111         $GLOBALS['beanList'] = $beanList;
112         $GLOBALS['beanFiles'] = $beanFiles;
113
114         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1);
115
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();
122
123     }
124
125     public function tearDown()
126     {
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();
134
135         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
136
137         unset($GLOBALS['current_user']);
138         unset($GLOBALS['beanList']);
139         unset($GLOBALS['beanFiles']);
140         unset($GLOBALS['app_list_strings']);
141         unset($_REQUEST);*/
142
143     }
144
145     /**
146      * Test checks if currency_id field remains with currency_id type
147      * @group 50768
148      */
149     public function testCurrencyIdType()
150     {
151         $cType = '';
152         $bean = BeanFactory::getBean($this->targetModule);
153         if(!empty($bean))
154         {
155             $fieldDefs = $bean->field_defs;
156             if(isset($fieldDefs['currency_id']))
157             {
158                 $cType = $fieldDefs['currency_id']['type'];
159             }
160         }
161
162         $this->assertEquals($cType, 'currency_id');
163     }
164
165     /**
166      * Test checks if there is 1 currency_id field for 2 currency fields
167      * @group 50768
168      */
169     public function testSettedCurrencyIdField()
170     {
171         $count = 0;
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 ) ) {
175             $count++;
176         }
177         $this->assertEquals($count, 1);
178     }
179 }