Ejemplo n.º 1
0
 public function testInstallerRepairTables()
 {
     $config = Config::getInstance();
     $config_array = $config->getValuesArray();
     $installer = Installer::getInstance();
     // test repair on healthy and complete tables
     Installer::$show_tables = array();
     $installer->populateTables($config_array);
     $expected = 'Your ThinkUp tables are <strong class="okay">complete</strong>.';
     $messages = $installer->repairTables($config_array);
     $this->assertIdentical($messages['table_complete'], $expected, $messages['table_complete']);
     // test repair on missing tables
     $this->DAO = new InstallerMySQLDAO($config_array);
     $q = "DROP TABLE " . $config->getValue('table_prefix') . "owners;";
     PDODAO::$PDO->exec($q);
     Installer::$show_tables = array();
     $expected = '/There are <strong class="not_okay">1 missing tables/i';
     $messages = $installer->repairTables($config_array);
     $this->assertPattern($expected, $messages['missing_tables']);
 }
 public function testFreshInstallStep3SuccessfulInstall()
 {
     self::time(__METHOD__);
     //get valid credentials
     $config = Config::getInstance();
     $valid_db_username = $config->getValue('db_user');
     $valid_db_pwd = $config->getValue('db_password');
     $valid_db_name = $config->getValue('db_name');
     $valid_db_host = $config->getValue('db_host');
     $valid_db_socket = $config->getValue('db_socket');
     //drop DB
     $this->testdb_helper->drop($this->test_database_name);
     //remove config file
     $config = null;
     Config::destroyInstance();
     //unset PDO so it must be recreated
     InstallerMySQLDAO::$PDO = null;
     //remove config file
     $this->removeConfigFile();
     //force a refresh of getTables
     Installer::$show_tables = null;
     //set param for step 3
     $_GET['step'] = '3';
     //set post values from form
     $_POST['site_email'] = "*****@*****.**";
     $_POST['password'] = "******";
     $_POST['confirm_password'] = "******";
     $_POST['db_user'] = $valid_db_username;
     $_POST['db_passwd'] = $valid_db_pwd;
     $_POST['db_name'] = $valid_db_name;
     //$_POST['db_name'] = 'thinkup_install';
     $_POST['db_type'] = "mysql";
     $_POST['db_host'] = $valid_db_host;
     $_POST['db_socket'] = $valid_db_socket;
     $_POST['db_port'] = "";
     $_POST['db_prefix'] = "tu_";
     $_POST['full_name'] = "My Full Name";
     $_POST['timezone'] = "America/Los_Angeles";
     $_SERVER['HTTP_HOST'] = "example.com";
     $controller = new InstallerController(true);
     $this->assertTrue(isset($controller));
     $result = $controller->go();
     $this->debug($result);
     $this->assertPattern('/ThinkUp has been successfully installed./', $result);
     $option_dao = DAOFactory::getDAO('OptionDAO');
     $current_stored_server_name = $option_dao->getOptionByName(OptionDAO::APP_OPTIONS, 'server_name');
     $this->assertNotNull($current_stored_server_name);
     $this->assertEqual($current_stored_server_name->option_value, 'example.com');
     $this->assertEqual($current_stored_server_name->option_name, 'server_name');
     $install_email = Mailer::getLastMail();
     $this->debug($install_email);
     $this->assertPattern("/http:\\/\\/example.com\\/session\\/activate.php\\?usr=you\\%40example.com\\&code\\=/", $install_email);
     $this->restoreConfigFile();
     //echo $result;
 }
Ejemplo n.º 3
0
 /**
  * Get SHOW TABLES at current $db
  *
  * @param array $config
  * @return array tables
  */
 public function showTables($config = null)
 {
     if (is_array(self::$show_tables) && !empty(self::$show_tables)) {
         return self::$show_tables;
     }
     if (!self::$installer_dao) {
         self::setDb($config);
     }
     self::$show_tables = self::$installer_dao->getTables();
     return self::$show_tables;
 }
Ejemplo n.º 4
0
 public function testFreshInstallStep3SuccessfulInstall()
 {
     //get valid credentials
     $config = Config::getInstance();
     $valid_db_username = $config->getValue('db_user');
     $valid_db_pwd = $config->getValue('db_password');
     $valid_db_name = $config->getValue('db_name');
     $valid_db_host = $config->getValue('db_host');
     $valid_db_socket = $config->getValue('db_socket');
     //drop DB
     $this->testdb_helper->drop($this->test_database_name);
     //remove config file
     $config = null;
     Config::destroyInstance();
     //unset PDO so it must be recreated
     InstallerMySQLDAO::$PDO = null;
     //remove config file
     $this->removeConfigFile();
     //force a refresh of getTables
     Installer::$show_tables = null;
     //set param for step 3
     $_GET['step'] = '3';
     //set post values from form
     $_POST['site_email'] = "*****@*****.**";
     $_POST['password'] = "******";
     $_POST['confirm_password'] = "******";
     $_POST['db_user'] = $valid_db_username;
     $_POST['db_passwd'] = $valid_db_pwd;
     $_POST['db_name'] = $valid_db_name;
     //$_POST['db_name'] = 'thinkup_install';
     $_POST['db_type'] = "mysql";
     $_POST['db_host'] = $valid_db_host;
     $_POST['db_socket'] = $valid_db_socket;
     $_POST['db_port'] = "";
     $_POST['db_prefix'] = "tu_";
     $_POST['full_name'] = "My Full Name";
     $_POST['timezone'] = "America/Los_Angeles";
     $_SERVER['HTTP_HOST'] = "http://example.com";
     $controller = new InstallerController(true);
     $this->assertTrue(isset($controller));
     $result = $controller->go();
     $this->assertPattern('/ThinkUp has been installed successfully./', $result);
     $this->restoreConfigFile();
     //echo $result;
 }