]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/modules/DynamicFields/EmptyCustomDateFieldTest.php
Release 6.2.0
[Github/sugarcrm.git] / tests / modules / DynamicFields / EmptyCustomDateFieldTest.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 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/TemplateDate.php';
39 require_once("modules/ModuleBuilder/controller.php");
40
41 /**
42  * This is testing a bug where a custom date field whos value was not set would cause a bad SQL query to prevent the other custom fields from saving correctly.
43  */
44 class EmptyCustomDateFieldTest extends Sugar_PHPUnit_Framework_TestCase
45 {
46     protected $targetModule = "Opportunities";
47     protected $secondCustomFieldName = "test_custom_c";
48     protected $dateFieldDef = array(
49         "module" => "ModuleBuilder",
50         "action" => "saveField",
51         "new_dropdown" => "",
52         "to_pdf" => "true",
53         "view_module" => "Opportunities",
54         "is_update" => "true",
55         "type" => "date",
56         "name" => "test_date_c",
57         "labelValue" => "test date_c",
58         "label" => "LBL_TEST_DATE_C",
59         "help" => "",
60         "comments" => "",
61         "default" => "",
62         "enforced" => "false",
63         "formula" => "",
64         "dependency" => "",
65         "reportableCheckbox" => "1",
66         "reportable" => "1",
67         "importable" => "true",
68         "duplicate_merge" => "0",
69     );
70
71     protected $extraFieldDef = array(
72         "module" => "ModuleBuilder",
73         "action" => "saveField",
74         "new_dropdown" => "",
75         "to_pdf" => "true",
76         "view_module" => "Opportunities",
77         "is_update" => "true",
78         "type" => "varchar",
79         "name" => "test_custom_c",
80         "labelValue" => "test custom_c",
81         "label" => "LBL_TEST_CUSTOM_C",
82         "help" => "",
83         "comments" => "",
84         "default" => "",
85         "len" => "255",
86         "orig_len" => "255",
87         "enforced" => "false",
88         "formula" => "",
89         "dependency" => "",
90         "reportableCheckbox" => "1",
91         "reportable" => "1",
92         "importable" => "true",
93         "duplicate_merge" => "0",
94     );
95
96     protected $testOpp;
97
98     public function setUp()
99     {
100         $this->markTestSkipped('causes all sorts of damage downhill');
101         $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
102         $beanList = array();
103         $beanFiles = array();
104         require('include/modules.php');
105         $GLOBALS['beanList'] = $beanList;
106         $GLOBALS['beanFiles'] = $beanFiles;
107         $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser();
108         $GLOBALS['current_user']->is_admin = 1;
109         $mbc = new ModuleBuilderController();
110         //Create the new Fields
111         $_REQUEST = $this->dateFieldDef;
112         $mbc->action_SaveField();
113         $_REQUEST = $this->extraFieldDef;
114         $mbc->action_SaveField();
115
116     }
117
118     public function tearDown()
119     {
120         /*$mbc = new ModuleBuilderController();
121         $_REQUEST = array(
122             "module" => "ModuleBuilder",
123             "action" => "DeleteField",
124             "to_pdf" => "true",
125             "view_module" => "Opportunities",
126             "is_update" => "true",
127             "type" => "date",
128             "name" => "test_date_c",
129             "label" => "LBL_TEST_DATE_C",
130             "type" => "date",
131             "name" => "test_date_c",
132             "labelValue" => "test date_c",
133             "label" => "LBL_TEST_DATE_C",
134             "help" => "",
135             "comments" => "",
136             "default" => "",
137             "enforced" => "false",
138             "formula" => "",
139             "dependency" => "",
140             "reportableCheckbox" => "1",
141             "reportable" => "1",
142             "importable" => "true",
143             "duplicate_merge" => "0",
144         );
145         $mbc->action_DeleteField();
146         $_REQUEST = array(
147             "module" => "ModuleBuilder",
148             "action" => "DeleteField",
149             "to_pdf" => "true",
150             "view_module" => "Opportunities",
151             "is_update" => "true",
152             "type" => "date",
153             "name" => "test_custom_c",
154             "label" => "LBL_TEST_DATE_C",
155             "type" => "varchar",
156             "name" => "test_custom_c",
157             "labelValue" => "test custom_c",
158             "label" => "LBL_TEST_CUSTOM_C",
159             "help" => "",
160             "comments" => "",
161             "default" => "",
162             "len" => "255",
163             "orig_len" => "255",
164             "enforced" => "false",
165             "formula" => "",
166             "dependency" => "",
167             "reportableCheckbox" => "1",
168             "reportable" => "1",
169             "importable" => "true",
170             "duplicate_merge" => "0",
171         );
172         $mbc->action_DeleteField();
173         
174         SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
175         unset($GLOBALS['current_user']);
176         unset($GLOBALS['beanList']);
177         unset($GLOBALS['beanFiles']);
178         unset($GLOBALS['app_list_strings']);
179         
180         if (!empty($this->testOpp)) {
181             $this->testOpp->mark_deleted($this->testOpp->id);
182         }*/
183     }
184
185     public function testSaveCustomDateField()
186     {
187
188         $this->testOpp = new Opportunity();
189         $this->testOpp->test_custom_c = "This should save";
190         $this->testOpp->save(false);
191
192         $this->testOpp->retrieve($this->testOpp->id);
193         $this->assertEquals("This should save", $this->testOpp->test_custom_c);
194     }
195
196 }
197
198 ?>