]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - tests/install/Bug40129Test.php
Release 6.2.0
[Github/sugarcrm.git] / tests / install / Bug40129Test.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5  * 
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.
12  * 
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
16  * details.
17  * 
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
21  * 02110-1301 USA.
22  * 
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.
25  * 
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.
29  * 
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  ********************************************************************************/
36
37  
38 require_once('install/install_utils.php');
39 require_once('modules/UpgradeWizard/uw_utils.php');
40
41 class Bug40129Test extends Sugar_PHPUnit_Framework_TestCase {
42
43 var $original_argv;
44 var $has_original_config_si_file;
45 var $current_working_dir;
46
47 public function setUp() {
48         global $argv;
49         if(isset($argv))
50         {
51                 $this->original_argv = $argv;
52         }
53         
54                 
55         $this->current_working_dir = getcwd();
56         
57         if(file_exists('config.php'))
58         {
59            copy('config.php', 'config.php.bug40129');
60         }       
61         
62         if(file_exists($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php'))
63         {
64            $this->has_original_config_si_file = true;
65            copy($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php', $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug40129');
66         } else {
67            $this->has_original_config_si_file = false;
68            copy('config.php', $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');              
69         }
70         
71         $sugar_config_si = array(       
72             'setup_db_host_name' => 'localhost',
73             'setup_db_database_name' => 'pineapple',
74             'setup_db_drop_tables' => 0,
75             'setup_db_create_database' => 1,
76             'setup_db_pop_demo_data' => false,
77             'setup_site_admin_user_name' => 'admin',
78             'setup_site_admin_password' => 'a',
79             'setup_db_create_sugarsales_user' => 0,
80             'setup_db_admin_user_name' => 'root',
81             'setup_db_admin_password' => '',
82             'setup_db_sugarsales_user' => 'root',
83             'setup_db_sugarsales_password' => '',
84             'setup_db_type' => 'mysql',
85             'setup_license_key_users' => 100,
86             'setup_license_key_expire_date' => '2010-12-25',
87             'setup_license_key_oc_licences' => 1,
88             'setup_license_key' => 'internal sugar user 20100224',
89             'setup_site_url' => 'http://localhost/pineapple/build/rome/builds/ent/sugarcrm',
90             'setup_system_name' => 'pineapple',
91             'default_currency_iso4217' => 'USD',
92             'default_currency_name' => 'US Dollars',
93             'default_currency_significant_digits' => '2',
94             'default_currency_symbol' => '$',
95             'default_date_format' => 'Y-m-d',
96             'default_time_format' => 'H:i',
97             'default_decimal_seperator' => '.',
98             'default_export_charset' => 'ISO-8859-1',
99             'default_language' => 'en_us',
100             'default_locale_name_format' => 's f l',
101             'default_number_grouping_seperator' => ',',
102             'export_delimiter' => ',',  
103         
104             //These are the additional configuration values we are really testing
105                 'disable_count_query' => true,
106                 'external_cache_disabled_apc' => true,
107                 'external_cache_disabled_zend' => true,
108                 'external_cache_disabled_memcache' => true,
109                 'external_cache_disabled' => true,
110         );
111         
112         write_array_to_file("sugar_config_si", $sugar_config_si, $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
113 }
114
115 public function tearDown() {
116         if(isset($this->original_argv))
117         {
118                 global $argv;
119                 $argv = $this->original_argv;
120         }
121         
122         if(file_exists('config.php.bug40129'))
123         {
124            copy('config.php.bug40129', 'config.php');
125            unlink('config.php.bug40129');
126         }               
127         
128         if(file_exists($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug40129'))
129         {
130            if($this->has_original_config_si_file) 
131            {
132                   copy($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug40129', $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
133            } else {
134                   unlink($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
135            }
136            unlink($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug40129');
137         }
138         else {
139             unlink($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
140         }
141
142 }
143         
144
145 public function test_silent_install() {
146         
147         if(!file_exists('config.php'))
148         {
149                 $this->markTestSkipped('Unable to locate config.php file.  Skipping test.');
150                 return;
151         }
152
153         
154         if(!file_exists($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php'))
155         {
156                 $this->markTestSkipped('Unable to locate config_si.php file.  Skipping test.');
157                 return;
158         }       
159         
160         $merge_result = merge_config_si_settings(false, 'config.php', $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
161         
162         include('config.php');
163         //echo var_export($sugar_config, true);
164         $this->assertEquals(true, $sugar_config['disable_count_query'], "Assert disable_count_query is set to true.");
165         $this->assertEquals(true, $sugar_config['external_cache_disabled_apc'], "Assert external_cache_disabled_apc is set to true.");
166         $this->assertEquals(true, $sugar_config['external_cache_disabled_zend'], "Assert external_cache_disabled_zend is set to true.");
167         $this->assertEquals(true, $sugar_config['external_cache_disabled_memcache'], "Assert external_cache_disabled_memcache is set to true.");
168         $this->assertEquals(true, $sugar_config['external_cache_disabled'], "Assert external_cache_disabled is set to true.");
169
170     $this->assertTrue(!isset($sugar_config['setup_site_admin_user_name']), "Assert setup_site_admin_user_name is not added to config.php.");
171     $this->assertTrue(!isset($sugar_config['setup_site_admin_password']), "Assert setup_site_admin_password is not added to config.php.");
172 }
173
174
175 }
176
177 ?>