]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/include/connectors/Bug40247Test.php
Release 6.2.0
[Github/sugarcrm.git] / tests / include / connectors / Bug40247Test.php
1 <?php
2
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38 class Bug40247Test extends Sugar_PHPUnit_Framework_TestCase 
39 {
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;
45     
46     function setUp() {
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');
51         }
52         
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');
57         }   
58
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');
63         } 
64
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');
69         } 
70
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');
75         }         
76         
77         if(file_exists('custom/modules/Connectors/metadata/mergeviewdefs.php')) {
78            unlink('custom/modules/Connectors/metadata/mergeviewdefs.php');
79         }
80         
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');
83         }
84     }
85     
86     function tearDown() {
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');
90         }       
91         
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');
95         }
96         
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');
100         }  
101
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');
105         }  
106
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');
110         }          
111     }
112     
113     
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.');
118         }
119         
120         $viewdefs = array();
121         
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.");
124         
125         $twitter_hover_link_set = false;
126         $linkedin_hover_link_set = false;
127         
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)
134                           {
135                                    if($entry == 'ext_rest_linkedin')
136                                    {
137                                          $linkedin_hover_link_set = true;
138                                    } else if($entry == 'ext_rest_twitter') {
139                                          $twitter_hover_link_set = true;
140                                    }
141                           }
142                                }
143                             }
144                         }
145                 }
146         }
147         
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.");
150         
151     }
152     
153     private function install_connectors() {
154         require('modules/Connectors/InstallDefaultConnectors.php');
155     }
156     
157 }  
158 ?>