2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 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 ********************************************************************************/
40 class Bug43471Test extends Sugar_PHPUnit_Framework_TestCase
43 private $_old_installing;
45 public function setUp()
47 $this->accountMockBean = $this->getMock('TestBean');
48 $this->_tablename = 'test' . date("YmdHis");
51 public function tearDown()
55 public function testDynamicFieldsRepairCustomFields()
57 $bean = $this->accountMockBean;
59 /** @var $df DynamicField */
60 $df = $this->getMock('DynamicField', array('createCustomTable'));
61 $bean->table_name = $this->_tablename;
62 $bean->field_defs = array (
70 'comment' => 'Unique identifier',
76 'dbType' => 'varchar',
77 'vname' => 'LBL_NAME',
79 'comment' => 'Name of the Company',
80 'unified_search' => true,
83 'importable' => 'required',
84 'merge_filter' => 'selected',
89 'source' => 'custom_fields',
91 'vname' => 'LBL_FOOBAR',
95 'comments' => 'LBL_FOOBAR_COMMENT',
96 'help' => 'LBL_FOOBAR_HELP',
97 'importable' => 'true',
98 'duplicate_merge' => 'disabled',
99 'duplicate_merge_dom_value' => '0',
101 'reportable' => true,
102 'calculated' => false,
105 'id' => 'AccountsFooBar_c',
106 'custom_module' => 'Accounts',
110 $df->expects($this->any())
111 ->method('createCustomTable')
112 ->will($this->returnValue(null));
114 $helper = $this->getMock('MysqliHelper');
115 $helper->expects($this->any())
116 ->method('get_columns')
117 ->will($this->returnValue(array(
118 'foobar_c' => array (
119 'name' => 'FooBar_c',
124 // set the new db helper
125 $GLOBALS['db']->helper = $helper;
127 $repair = $df->repairCustomFields(false);
128 $this->assertEquals("", $repair);
130 // reset the db helper
131 $GLOBALS['db']->helper = null;
137 require_once("include/SugarObjects/templates/company/Company.php");
139 // Account is used to store account information.
140 class TestBean extends Company {