3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 class Bug40247Test extends Sugar_PHPUnit_Framework_TestCase
40 var $has_custom_connectors_file;
41 var $has_custom_display_config_file;
42 var $has_custom_accounts_detailviewdefs_file;
43 var $has_custom_leads_detailviewdefs_file;
44 var $has_custom_contacts_detailviewdefs_file;
47 if(file_exists('custom/modules/connectors/metadata/connectors.php')) {
48 $this->has_custom_connectors_file = true;
49 copy('custom/modules/connectors/metadata/connectors.php', 'custom/modules/connectors/metadata/connectors.php.bak');
50 unlink('custom/modules/connectors/metadata/connectors.php');
53 if(file_exists('custom/modules/connectors/metadata/display_config.php')) {
54 $this->has_custom_display_config_file = true;
55 copy('custom/modules/connectors/metadata/display_config.php', 'custom/modules/connectors/metadata/display_config.php.bak');
56 unlink('custom/modules/connectors/metadata/display_config.php');
59 if(file_exists('custom/modules/accounts/metadata/detailviewdefs.php')) {
60 $this->has_custom_accounts_detailviewdefs_file = true;
61 copy('custom/modules/accounts/metadata/detailviewdefs.php', 'custom/modules/accounts/metadata/detailviewdefs.php.bak');
62 unlink('custom/modules/accounts/metadata/detailviewdefs.php');
65 if(file_exists('custom/modules/contactss/metadata/detailviewdefs.php')) {
66 $this->has_custom_contacts_detailviewdefs_file = true;
67 copy('custom/modules/contacts/metadata/detailviewdefs.php', 'custom/modules/contacts/metadata/detailviewdefs.php.bak');
68 unlink('custom/modules/contacts/metadata/detailviewdefs.php');
71 if(file_exists('custom/modules/accounts/metadata/detailviewdefs.php')) {
72 $this->has_custom_leads_detailviewdefs_file = true;
73 copy('custom/modules/leads/metadata/detailviewdefs.php', 'custom/modules/leads/metadata/detailviewdefs.php.bak');
74 unlink('custom/modules/leads/metadata/detailviewdefs.php');
77 if(file_exists('custom/modules/Connectors/metadata/mergeviewdefs.php')) {
78 unlink('custom/modules/Connectors/metadata/mergeviewdefs.php');
81 if(file_exists('custom/modules/Connectors/connectors/sources/ext/rest/linkedin/mapping.php')) {
82 unlink('custom/modules/Connectors/connectors/sources/ext/rest/linkedin/mapping.php');
87 if($this->has_custom_connectors_file) {
88 copy('custom/modules/connectors/metadata/connectors.php.bak', 'custom/modules/connectors/metadata/connectors.php');
89 unlink('custom/modules/connectors/metadata/connectors.php.bak');
92 if($this->has_custom_display_config_file) {
93 copy('custom/modules/connectors/metadata/display_config.php.bak', 'custom/modules/connectors/metadata/display_config.php');
94 unlink('custom/modules/connectors/metadata/display_config.php.bak');
97 if($this->has_custom_accounts_detailviewdefs_file) {
98 copy('custom/modules/accounts/metadata/detailviewdefs.php.bak', 'custom/modules/accounts/metadata/detailviewdefs.php');
99 unlink('custom/modules/accounts/metadata/detailviewdefs.php.bak');
102 if($this->has_custom_contacts_detailviewdefs_file) {
103 copy('custom/modules/contacts/metadata/detailviewdefs.php.bak', 'custom/modules/contacts/metadata/detailviewdefs.php');
104 unlink('custom/modules/contacts/metadata/detailviewdefs.php.bak');
107 if($this->has_custom_leads_detailviewdefs_file) {
108 copy('custom/modules/leads/metadata/detailviewdefs.php.bak', 'custom/modules/leads/metadata/detailviewdefs.php');
109 unlink('custom/modules/leads/metadata/detailviewdefs.php.bak');
114 function test_default_com_connectors() {
115 $this->install_connectors();
116 if(!file_exists('custom/modules/connectors/metadata/display_config.php')) {
117 $this->markTestSkipped('Mark test skipped. Likely no permission to write to custom directory.');
122 require('modules/Accounts/metadata/detailviewdefs.php');
123 $this->assertFalse(in_array('CONNECTOR', $viewdefs['Accounts']['DetailView']['templateMeta']['form']['buttons']), "Assert that the Get Data button is not added to Accounts detailviewdefs.php file.");
125 $twitter_hover_link_set = false;
126 $linkedin_hover_link_set = false;
128 foreach($viewdefs['Accounts']['DetailView']['panels'] as $panels) {
129 foreach($panels as $panel) {
130 foreach($panel as $row=>$col) {
131 if(is_array($col) && $col['name'] == 'name') {
132 if(isset($col['displayParams']) && isset($col['displayParams']['connectors'])) {
133 foreach($col['displayParams']['connectors'] as $entry)
135 if($entry == 'ext_rest_linkedin')
137 $linkedin_hover_link_set = true;
138 } else if($entry == 'ext_rest_twitter') {
139 $twitter_hover_link_set = true;
148 $this->assertFalse($twitter_hover_link_set, "Assert that the Twitter hover link is not set for Accounts.");
149 $this->assertTrue($linkedin_hover_link_set, "Assert that the LinkedIn hover link is set for Accounts.");
153 private function install_connectors() {
154 require('modules/Connectors/InstallDefaultConnectors.php');