2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 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 class Bug40658Test extends Sugar_PHPUnit_Framework_TestCase
40 public function setup()
42 require('include/modules.php');
43 $GLOBALS['beanList'] = $beanList;
44 $GLOBALS['beanFiles'] = $beanFiles;
45 //$this->useOutputBuffering = false;
48 public function testGetRelateJoin()
50 require_once('modules/DynamicFields/DynamicField.php');
51 $dynamicField = new DynamicField();
52 $account = new Account();
53 $dynamicField->bean = $account;
59 'name' => 'm1_related_c',
60 'vname' => 'LBL_M1_RELATED',
67 'duplicate_merge' => 'disabled',
68 'duplicate_merge_dom_value' => 0,
74 'id_name' => 'def_m1_id_c',
76 'module' => 'Accounts',
78 'quicksearch' => 'enabled',
79 'studio' => 'visible',
80 'id' => 'def_M1m1_related_c',
81 'custom_module' => 'Accounts',
84 $joinTableAlias = 'jt1';
85 $relatedJoinInfo = $dynamicField->getRelateJoin($field_def, $joinTableAlias);
86 //echo var_export($relatedJoinInfo, true);
87 $this->assertEquals(', accounts_cstm.def_m1_id_c, jt1.name m1_related_c ', $relatedJoinInfo['select']);
90 public function testSubpanelMetaDataParser()
92 $subpanelMetaDataParser = new SubpanelMetaDataParserMock('Bug40658Test', 'Accounts');
93 $defs = array('m1_related_c' =>
97 'studio' => 'visible',
98 'vname' => 'LBL_M2_RELATED',
102 $result = $subpanelMetaDataParser->makeRelateFieldsAsLink($defs);
103 $this->assertEquals('SubPanelDetailViewLink', $result['m1_related_c']['widget_class']);
104 $this->assertEquals('def_M1', $result['m1_related_c']['target_module']);
105 $this->assertEquals('def_m1_id_c', $result['m1_related_c']['target_record_key']);
109 require_once('modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php');
111 class SubpanelMetaDataParserMock extends SubpanelMetaDataParser
113 //Override constructor... don't do anything
114 function __construct ($subpanelName , $moduleName , $packageName = '')
119 public function makeRelateFieldsAsLink($defs)
121 $this->_moduleName = 'def_M1';
122 $this->_fielddefs = array('m1_related_c' =>
126 'source' => 'non-db',
127 'name' => 'm1_related_c',
128 'vname' => 'LBL_M1_RELATED',
134 'importable' => 'true',
135 'duplicate_merge' => 'disabled',
136 'duplicate_merge_dom_value' => '0',
138 'reportable' => true,
139 'calculated' => false,
142 'id_name' => 'def_m1_id_c',
144 'module' => 'def_M1',
146 'quicksearch' => 'enabled',
147 'studio' => 'visible',
148 'id' => 'def_M1m1_related_c',
149 'custom_module' => 'def_M1',
150 'label' => 'm1_related_c',
152 'widget_class' => 'SubPanelDetailViewLink',
153 'target_module' => 'def_M1',
154 'target_record_key' => 'def_m1_id_c',
160 return parent::makeRelateFieldsAsLink($defs);