2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 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('install/install_utils.php');
39 require_once('modules/UpgradeWizard/uw_utils.php');
41 class Bug37214Test extends Sugar_PHPUnit_Framework_TestCase {
44 var $has_original_config_si_file;
45 var $current_working_dir;
47 public function setUp() {
51 $this->original_argv = $argv;
55 $this->current_working_dir = getcwd();
57 $sugar_config_si = array(
58 'disable_count_query' => true,
59 'external_cache_disabled_apc' => true,
60 'external_cache_disabled_zend' => true,
61 'external_cache_disabled_memcache' => true,
62 'external_cache_disabled' => true,
65 if(file_exists('config.php'))
67 copy('config.php', 'config.php.bug37214');
69 // remove items since merge_config_si_settings does not merge existing keys
70 foreach($sugar_config_si as $k => $v) {
71 unset($sugar_config[$k]);
73 write_array_to_file("sugar_config", $sugar_config, 'config.php');
76 if(file_exists('config_si.php'))
78 $this->has_original_config_si_file = true;
79 copy('config_si.php', 'config_si.php.bug37214');
81 $this->has_original_config_si_file = false;
82 copy('config.php', 'config_si.php');
85 write_array_to_file("sugar_config_si", $sugar_config_si, 'config_si.php');
88 public function tearDown() {
89 if(isset($this->original_argv))
92 $argv = $this->original_argv;
95 if(file_exists('config.php.bug37214'))
97 copy('config.php.bug37214', 'config.php');
98 unlink('config.php.bug37214');
101 if(file_exists($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug37214'))
103 if($this->has_original_config_si_file)
105 copy($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug37214', $this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
107 unlink($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
109 unlink($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php.bug37214');
112 unlink($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php');
117 public function test_silent_upgrade_parameters() {
118 if(!file_exists('config.php'))
120 $this->markTestSkipped('Unable to locate config.php file. Skipping test.');
125 if(!file_exists($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php'))
127 $this->markTestSkipped('Unable to locate config_si.php file. Skipping test.');
131 //Simulate silent upgrade arguments
133 $argv[0] = $this->current_working_dir . DIRECTORY_SEPARATOR . 'config.php'; //This would really be silentUpgrade.php, but this will suffice
134 $argv[1] = $this->current_working_dir . DIRECTORY_SEPARATOR . 'someZipFile.php';
135 $argv[2] = $this->current_working_dir . DIRECTORY_SEPARATOR . 'silent_upgrade.log';
136 $argv[3] = $this->current_working_dir;
139 $merge_result = merge_config_si_settings();
141 include('config.php');
142 //echo var_export($sugar_config, true);
143 $this->assertEquals(true, $sugar_config['disable_count_query'], "Assert disable_count_query is set to true.");
144 $this->assertEquals(true, $sugar_config['external_cache_disabled_apc'], "Assert external_cache_disabled_apc is set to true.");
145 $this->assertEquals(true, $sugar_config['external_cache_disabled_zend'], "Assert external_cache_disabled_zend is set to true.");
146 $this->assertEquals(true, $sugar_config['external_cache_disabled_memcache'], "Assert external_cache_disabled_memcache is set to true.");
147 $this->assertEquals(true, $sugar_config['external_cache_disabled'], "Assert external_cache_disabled is set to true.");
152 * test_silent_upgrade_parameters2
153 * This is similar to test_silent_upgrade_parameters except that $argv[0] simulates the current directory
154 * (imagine the caes of something like >php silentUpgrade.php xxx yyy zzz). This is to prove that the
155 * merge_config_si_settings() can correctly determine the presence of the config_si.php file given the
159 public function test_silent_upgrade_parameters2() {
161 if(!file_exists('config.php'))
163 $this->markTestSkipped('Unable to locate config.php file. Skipping test.');
168 if(!file_exists($this->current_working_dir . DIRECTORY_SEPARATOR . 'config_si.php'))
170 $this->markTestSkipped('Unable to locate config_si.php file. Skipping test.');
174 //Simulate silent upgrade arguments
176 $argv[0] = 'config.php'; //This would really be silentUpgrade.php, but this will suffice
177 $argv[1] = $this->current_working_dir . DIRECTORY_SEPARATOR . 'someZipFile.php';
178 $argv[2] = $this->current_working_dir . DIRECTORY_SEPARATOR . 'silent_upgrade.log';
179 $argv[3] = $this->current_working_dir;
182 $merge_result = merge_config_si_settings(true);
183 //$this->assertEquals(true, $merge_result, "Assert that we have merged values");
185 include('config.php');
186 //echo var_export($sugar_config, true);
187 $this->assertEquals(true, $sugar_config['disable_count_query'], "Assert disable_count_query is set to true.");
188 $this->assertEquals(true, $sugar_config['external_cache_disabled_apc'], "Assert external_cache_disabled_apc is set to true.");
189 $this->assertEquals(true, $sugar_config['external_cache_disabled_zend'], "Assert external_cache_disabled_zend is set to true.");
190 $this->assertEquals(true, $sugar_config['external_cache_disabled_memcache'], "Assert external_cache_disabled_memcache is set to true.");
191 $this->assertEquals(true, $sugar_config['external_cache_disabled'], "Assert external_cache_disabled is set to true.");