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 require_once('include/SubPanel/SubPanelTilesTabs.php');
42 * Custom relationships under same module only show once in subpanel tabs
46 class Bug44344Test extends Sugar_PHPUnit_Framework_TestCase
52 public function setUp()
54 global $beanList, $beanFiles;
55 require('include/modules.php');
57 $GLOBALS['current_user'] = SugarTestUserUtilities::createAnonymousUser(true, 1);
58 $GLOBALS['current_user']->setPreference('max_tabs', '7');
60 // create vardef to add new relation account - cases
61 $this->addNewRelationships();
63 // add new tabgroup whit cases module
64 unset($GLOBALS['tabStructure']);
65 $this->group_label = 'LBL_GROUPTAB_'.mktime();
66 $GLOBALS['tabStructure'][$this->group_label] = array(
67 'label' => $this->group_label,
68 'modules' => array('Cases')
71 $this->account = SugarTestAccountUtilities::createAccount();
74 public function tearDown()
76 SugarTestAccountUtilities::removeAllCreatedAccounts();
77 unset($this->account);
79 unset($GLOBALS['tabStructure']);
80 unset($this->subPanel, $this->group_label);
81 unset($GLOBALS['dictionary']["accounts_cases_10000"]);
83 SugarTestUserUtilities::removeAllCreatedAnonymousUsers();
84 unset($GLOBALS['current_user']);
86 unset($GLOBALS['beanFiles']);
87 unset($GLOBALS['beanList']);
91 * add new relation accounts_cases_10000 (Account to Cases: one-to-many)
94 private function addNewRelationships()
96 $GLOBALS['dictionary']["accounts_cases_10000"] = array (
97 'true_relationship_type' => 'one-to-many',
98 'from_studio' => true,
101 'accounts_cases_10000' =>
103 'lhs_module' => 'Accounts',
104 'lhs_table' => 'accounts',
106 'rhs_module' => 'Cases',
107 'rhs_table' => 'cases',
109 'relationship_type' => 'many-to-many',
110 'join_table' => 'accounts_cases_10000_c',
111 'join_key_lhs' => 'accounts_cases_10000accounts_ida',
112 'join_key_rhs' => 'accounts_cases_10000cases_idb',
115 'table' => 'accounts_cases_10000_c',
118 0 => array ('name' => 'id', 'type' => 'varchar', 'len' => 36),
119 1 => array ('name' => 'date_modified', 'type' => 'datetime'),
120 2 => array ('name' => 'deleted', 'type' => 'bool', 'len' => '1', 'default' => '0', 'required' => true),
121 3 => array ('name' => 'accounts_cases_10000accounts_ida', 'type' => 'varchar', 'len' => 36),
122 4 => array ('name' => 'accounts_cases_10000cases_idb', 'type' => 'varchar', 'len' => 36),
126 0 => array ('name' => 'accounts_cases_10000spk', 'type' => 'primary', 'fields' => array (0 => 'id')),
127 1 => array ('name' => 'accounts_cases_10000_ida1', 'type' => 'index', 'fields' => array (0 => 'accounts_cases_10000accounts_ida')),
128 2 => array ('name' => 'accounts_cases_10000_alt', 'type' => 'alternate_key', 'fields' => array (0 => 'accounts_cases_10000cases_idb')),
134 * generate mock layout_defs for SubPanelDefinitions object
135 * add two subpanels: cases (default relation) and accounts_cases_10000 (test created relation)
138 private function getLayoutDefs()
140 $layout_defs = array();
142 $layout_defs["subpanel_setup"]['cases'] = array(
144 'sort_order' => 'desc',
145 'sort_by' => 'case_number',
147 'subpanel_name' => 'ForAccounts',
148 'get_subpanel_data' => 'cases',
149 'add_subpanel_data' => 'case_id',
150 'title_key' => 'LBL_CASES_SUBPANEL_TITLE',
151 'top_buttons' => array(
152 array('widget_class' => 'SubPanelTopButtonQuickCreate'),
153 array('widget_class' => 'SubPanelTopSelectButton', 'mode'=>'MultiSelect')
157 $layout_defs["subpanel_setup"]['accounts_cases_10000'] = array (
160 'subpanel_name' => 'default',
161 'sort_order' => 'asc',
163 'title_key' => 'LBL_ACCOUNTS_CASES_FROM_CASES_TITLE',
164 'get_subpanel_data' => 'accounts_cases_10000',
171 * @outputBuffering enabled
173 public function testSubPanelTilesTabsGetTabs()
175 $tabs = array('cases', 'accounts_cases_10000');
176 $this->subPanel = new SubPanelTilesTabs($this->account, '', $this->getLayoutDefs());
178 // get tabs by selected group ($this->group_label)
179 $returned_tabs = $this->subPanel->getTabs($tabs, true, $this->group_label);
181 foreach ( $tabs as $tab )
183 $this->assertContains($tab, $returned_tabs);