Example #1
0
 /**
  * Tests update scripts list
  *
  * @return void
  */
 public function testGetUpgradeScripts()
 {
     $update_scripts = \Galette\Core\Install::getUpdateScripts(GALETTE_BASE_PATH . '/install', 'pgsql', '0.6');
     $knowns = array('0.60' => 'upgrade-to-0.60-pgsql.sql', '0.61' => 'upgrade-to-0.61-pgsql.sql', '0.62' => 'upgrade-to-0.62-pgsql.sql', '0.63' => 'upgrade-to-0.63-pgsql.sql', '0.70' => 'upgrade-to-0.70.php', '0.71' => 'upgrade-to-0.71-pgsql.sql', '0.74' => 'upgrade-to-0.74-pgsql.sql', '0.75' => 'upgrade-to-0.75-pgsql.sql', '0.76' => 'upgrade-to-0.76-pgsql.sql', '0.8' => 'upgrade-to-0.8.php', '0.81' => 'upgrade-to-0.81-pgsql.sql', '0.82' => 'upgrade-to-0.82-pgsql.sql');
     //as of 0.8, we got 10 update scripts total
     $this->array($update_scripts)->hasSize(count($knowns))->isIdenticalTo($knowns);
     $update_scripts = \Galette\Core\Install::getUpdateScripts(GALETTE_BASE_PATH . '/install', 'pgsql', '0.7');
     //if we're from 0.7.0, there are only 6 update scripts left
     $this->array($update_scripts)->hasSize(count($knowns) - 4);
     $update_scripts = \Galette\Core\Install::getUpdateScripts(GALETTE_BASE_PATH . '/install');
     //without specifying database nor version, we got 10 update scripts total
     $this->array(array_values($update_scripts))->hasSize(count($knowns))->isEqualTo(array_keys($knowns));
     $this->_install->setMode(\Galette\Core\Install::UPDATE);
     $errors = array();
     $this->_install->setDbType(\Galette\Core\Db::PGSQL, $errors);
     $this->_install->setInstalledVersion('0.6');
     $update_scripts = $this->_install->getScripts(GALETTE_BASE_PATH . '/install');
     $this->array($update_scripts)->hasSize(count($knowns))->isIdenticalTo($knowns);
     $this->_install->setMode(\Galette\Core\Install::INSTALL);
     $update_scripts = $this->_install->getScripts(GALETTE_BASE_PATH . '/install');
     $this->array($update_scripts)->hasSize(1)->hasKey('current')->strictlyContains(\Galette\Core\Db::PGSQL . '.sql');
 }
     $update_scripts = Install::getUpdateScripts($plugin['root'], TYPE_DB);
     $tpl->assign('update_scripts', $update_scripts);
     $title = _T("Previous version selection");
     break;
 case 'i4':
 case 'u4':
     if ($step == 'i4') {
         $title = _T("Creation of the tables");
     } else {
         $title = _T("Update of the tables");
     }
     // begin : copyright (2002) the phpbb group (support@phpbb.com)
     // load in the sql parser
     include GALETTE_ROOT . 'includes/sql_parse.php';
     if ($step == 'u4') {
         $update_scripts = Install::getUpdateScripts($plugin['root'], TYPE_DB, $_POST['previous_version']);
     } else {
         $update_scripts['current'] = TYPE_DB . '.sql';
     }
     $sql_query = '';
     while (list($key, $val) = each($update_scripts)) {
         $sql_query .= @fread(@fopen($plugin['root'] . '/scripts/' . $val, 'r'), @filesize($plugin['root'] . '/scripts/' . $val));
         $sql_query .= "\n";
     }
     $sql_query = preg_replace('/galette_/', PREFIX_DB, $sql_query);
     $sql_query = remove_remarks($sql_query);
     $sql_query = split_sql_file($sql_query, ';');
     for ($i = 0; $i < sizeof($sql_query); $i++) {
         $query = trim($sql_query[$i]);
         if ($query != '' && $query[0] != '-') {
             //some output infos