/** * @maxattempts 1 */ public function testUpgrade() { $before = $this->beforeUpgrade(); $sourceFolder = static::getShopManager()->getNewConfiguration()->getAsAbsolutePath('shop.filesystem_path'); // If we put an autoupgrade module in the source of the target version, use this one. $autoupgradeSourceFolder = FS::join($sourceFolder, 'modules', 'autoupgrade'); if (FS::exists($autoupgradeSourceFolder)) { $autoupgradeTargetFolder = FS::join($this->shop->getFilesystemPath(), 'modules', 'autoupgrade'); $this->shop->getFileManager()->webCopyShopFiles($autoupgradeSourceFolder, $autoupgradeTargetFolder); } // Install autoupgrade $this->shop->getBackOfficeNavigator()->installModule('autoupgrade'); // Copy files from the target version $targetFolder = FS::join($this->shop->getBackOfficeFolderPath(), 'autoupgrade', 'latest', 'prestashop'); // copy via a script executed by the browser to go around permissions issues $this->shop->getFileManager()->webCopyShopFiles($sourceFolder, $targetFolder); $this->shop->getBrowser()->click('#currentConfiguration input[type="submit"]')->click('input[value*=Expert]')->select('[name="channel"]', 'directory')->fillIn('[name="directory_num"]', '1.6.1.0')->click('[name="submitConf-channel"]')->acceptAlert()->click('#upgradeNow')->waitFor("{xpath}//h3[contains(., 'Upgrade Complete!')]", 120); $this->afterUpgrade($before); }
protected function guessShopSettings($folder) { $guessed = []; if (is_readable($path = FS::join($folder, 'config', 'settings.inc.php'))) { $exp = '/\\bdefine\\s*\\(\\s*([\'"])(.*?)\\1\\s*,\\s*([\'"])(.*?)\\3\\s*\\)/'; $m = []; $n = preg_match_all($exp, file_get_contents($path), $m); $options = []; for ($i = 0; $i < $n; $i++) { $options[$m[2][$i]] = $m[4][$i]; } if (isset($options['_DB_SERVER_'])) { $hp = explode(':', $options['_DB_SERVER_']); $guessed['mysql_host'] = $hp[0]; $guessed['mysql_port'] = isset($hp[1]) ? $hp[1] : '3306'; } $map = ['_DB_NAME_' => 'mysql_database', '_DB_USER_' => 'mysql_user', '_DB_PASSWD_' => 'mysql_pass', '_DB_PREFIX_' => 'database_prefix', '_PS_VERSION_' => 'prestashop_version']; foreach ($map as $native => $name) { if (isset($options[$native])) { $guessed[$name] = $options[$native]; } } } $back_office_folder_name = false; $install_folder_name = false; foreach (scandir($folder) as $entry) { if ($entry[0] !== '.' && is_dir(FS::join($folder, $entry))) { if (FS::exists($folder, $entry, 'index_cli.php')) { $install_folder_name = $entry; } elseif (FS::exists($folder, $entry, 'ajax-tab.php')) { $back_office_folder_name = $entry; } } } if ($back_office_folder_name !== false) { $guessed['back_office_folder_name'] = $back_office_folder_name; } if ($install_folder_name !== false) { $guessed['install_folder_name'] = $install_folder_name; } return $guessed; }