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/TemplateDate.php';
39 require_once("modules/ModuleBuilder/controller.php");
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.
44 class EmptyCustomDateFieldTest extends Sugar_PHPUnit_Framework_TestCase
46 protected $targetModule = "Opportunities";
47 protected $secondCustomFieldName = "test_custom_c";
48 protected $dateFieldDef = array(
49 "module" => "ModuleBuilder",
50 "action" => "saveField",
53 "view_module" => "Opportunities",
54 "is_update" => "true",
56 "name" => "test_date_c",
57 "labelValue" => "test date_c",
58 "label" => "LBL_TEST_DATE_C",
62 "enforced" => "false",
65 "reportableCheckbox" => "1",
67 "importable" => "true",
68 "duplicate_merge" => "0",
71 protected $extraFieldDef = array(
72 "module" => "ModuleBuilder",
73 "action" => "saveField",
76 "view_module" => "Opportunities",
77 "is_update" => "true",
79 "name" => "test_custom_c",
80 "labelValue" => "test custom_c",
81 "label" => "LBL_TEST_CUSTOM_C",
87 "enforced" => "false",
90 "reportableCheckbox" => "1",
92 "importable" => "true",
93 "duplicate_merge" => "0",
98 public function setUp()
100 $this->markTestIncomplete('causes all sorts of damage downhill');
101 $GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
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();
118 public function tearDown()
120 /*$mbc = new ModuleBuilderController();
122 "module" => "ModuleBuilder",
123 "action" => "DeleteField",
125 "view_module" => "Opportunities",
126 "is_update" => "true",
128 "name" => "test_date_c",
129 "label" => "LBL_TEST_DATE_C",
131 "name" => "test_date_c",
132 "labelValue" => "test date_c",
133 "label" => "LBL_TEST_DATE_C",
137 "enforced" => "false",
140 "reportableCheckbox" => "1",
142 "importable" => "true",
143 "duplicate_merge" => "0",
145 $mbc->action_DeleteField();
147 "module" => "ModuleBuilder",
148 "action" => "DeleteField",
150 "view_module" => "Opportunities",
151 "is_update" => "true",
153 "name" => "test_custom_c",
154 "label" => "LBL_TEST_DATE_C",
156 "name" => "test_custom_c",
157 "labelValue" => "test custom_c",
158 "label" => "LBL_TEST_CUSTOM_C",
164 "enforced" => "false",
167 "reportableCheckbox" => "1",
169 "importable" => "true",
170 "duplicate_merge" => "0",
172 $mbc->action_DeleteField();
174 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
175 unset($GLOBALS['current_user']);
176 unset($GLOBALS['beanList']);
177 unset($GLOBALS['beanFiles']);
178 unset($GLOBALS['app_list_strings']);
180 if (!empty($this->testOpp)) {
181 $this->testOpp->mark_deleted($this->testOpp->id);
185 public function testSaveCustomDateField()
188 $this->testOpp = new Opportunity();
189 $this->testOpp->test_custom_c = "This should save";
190 $this->testOpp->save(false);
192 $this->testOpp->retrieve($this->testOpp->id);
193 $this->assertEquals("This should save", $this->testOpp->test_custom_c);