本文整理汇总了PHP中Config::destroyInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::destroyInstance方法的具体用法?PHP Config::destroyInstance怎么用?PHP Config::destroyInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::destroyInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreateDatabase
public function testCreateDatabase() {
$config = Config::getInstance();
$config_array = $config->getValuesArray();
$dao = new InstallerMySQLDAO($config_array);
$config_array['db_name'] = 'thinkup_db_creation_test_db-yes';
//Check that the database exists before trying to create it.
$before = $this->testdb_helper->databaseExists($config_array['db_name']);
$this->assertFalse($before);
//Create the database. True on success, false on fail.
//Destroy the current correct config array, replaced with the test db
//name array in the createInstallDatabase function
Config::destroyInstance();
$create_db = $dao->createInstallDatabase($config_array);
//Check the database exists after creation.
Config::destroyInstance();
$after = $this->testdb_helper->databaseExists($config_array['db_name']);
$this->assertTrue($create_db && $after);
//Delete the database. True on success, false on fail.
$deleted = $this->testdb_helper->deleteDatabase($config_array['db_name']);
//Assert that the testing database for this function was cleaned up
$this->assertTrue($deleted);
}
示例2: tearDown
/**
* Destroy Config, Webapp, $_SESSION, $_POST, $_GET, $_REQUEST
*/
public function tearDown()
{
Config::destroyInstance();
PluginRegistrarWebapp::destroyInstance();
PluginRegistrarCrawler::destroyInstance();
if (isset($_SESSION)) {
$this->unsetArray($_SESSION);
}
$this->unsetArray($_POST);
$this->unsetArray($_GET);
$this->unsetArray($_REQUEST);
$this->unsetArray($_SERVER);
$this->unsetArray($_FILES);
Loader::unregister();
$backup_dir = FileDataManager::getBackupPath();
if (file_exists($backup_dir)) {
try {
@exec('cd ' . $backup_dir . '; rm -rf *');
rmdir($backup_dir);
// won't delete if has files
} catch (Exception $e) {
}
}
$data_dir = FileDataManager::getDataPath();
if (file_exists($data_dir . 'compiled_view')) {
try {
@exec('cd ' . $data_dir . '; rm -rf compiled_view');
} catch (Exception $e) {
}
}
parent::tearDown();
}
示例3: testCreateDatabase
public function testCreateDatabase()
{
$config = Config::getInstance();
$config_array = $config->getValuesArray();
$dao = new InstallerMySQLDAO($config_array);
//test a hairy database name with dashes to assert escaping is happening correctly
$config_array['db_name'] = 'thinkup_db_creation-test_db-yes';
//Check that the database exists before trying to create it.
$before = $this->testdb_helper->databaseExists($config_array['db_name']);
$this->assertFalse($before);
//Create the database. True on success, false on fail.
//Destroy the current correct config, replace with the test db name array in the createInstallDatabase function
Config::destroyInstance();
$create_db = $dao->createInstallDatabase($config_array);
//Check the database exists after creation.
Config::destroyInstance();
$after = $this->testdb_helper->databaseExists($config_array['db_name']);
$this->assertTrue($create_db);
$this->assertTrue($after);
//Delete the database
$this->testdb_helper->deleteDatabase($config_array['db_name']);
//Assert it no longer exists
$after = $this->testdb_helper->databaseExists($config_array['db_name']);
$this->assertFalse($after);
}
示例4: getDBType
/**
* Gets the db_type for our configured ThinkUp instance, defaults to mysql,
* db_type can optionally be defined in webapp/config.inc as:
*
*<code>
* $THINKUP_CFG['db_type'] = 'somedb';
*</code>
*
* @param array $cfg_vals Optionally override config.inc.php vals; needs 'table_prefix', 'db_type',
* 'db_socket', 'db_name', 'db_host', 'db_user', 'db_password'
* @return string db_type, will default to 'mysql' if not defined
*/
public static function getDBType($cfg_vals = null)
{
if ($cfg_vals != null) {
Config::destroyInstance();
}
$type = Config::getInstance($cfg_vals)->getValue('db_type');
$type = is_null($type) ? 'mysql' : $type;
return $type;
}
示例5: tearDown
/**
* Tear down
* Destroys Config, Webapp, and Session objects
* @TODO Destroy all SESSION variables
* @TODO Destroy all REQUEST/GET/POST variables
*/
function tearDown()
{
Config::destroyInstance();
Webapp::destroyInstance();
Crawler::destroyInstance();
if (isset($_SESSION['user'])) {
$_SESSION['user'] = null;
}
parent::tearDown();
}
示例6: testNoConfigFileNoArray
public function testNoConfigFileNoArray()
{
Config::destroyInstance();
$this->removeConfigFile();
try {
$config = Config::getInstance();
$this->assertNull($config->getValue('table_prefix'));
} catch (Exception $e) {
$this->assertPattern("/ThinkUp's configuration file does not exist!/", $e->getMessage());
}
$this->restoreConfigFile();
}
示例7: testNewViewManagerWithoutConfigFile
/**
* Test constructor
*/
public function testNewViewManagerWithoutConfigFile()
{
$orig_tz = date_default_timezone_get();
$this->removeConfigFile();
Config::destroyInstance();
$cfg_array = array('site_root_path' => Utils::getSiteRootPathFromFileSystem(), 'source_root_path' => THINKUP_ROOT_PATH, 'datadir_path' => THINKUP_WEBAPP_PATH . 'data/', 'debug' => false, 'app_title_prefix' => "", 'cache_pages' => false);
$v_mgr = new ViewManager($cfg_array);
$tz = date_default_timezone_get();
$this->assertEqual($tz, 'UTC');
$this->assertTrue(isset($v_mgr));
$this->restoreConfigFile();
date_default_timezone_set($orig_tz);
}
示例8: testGetDataPathConfigExistsWithoutDataDirValue
public function testGetDataPathConfigExistsWithoutDataDirValue()
{
Config::destroyInstance();
$this->removeConfigFile();
$cfg_values = array("table_prefix" => "thinkupyo", "db_host" => "myserver.com");
$config = Config::getInstance($cfg_values);
//test just path
$path = FileDataManager::getDataPath();
$this->assertEqual($path, THINKUP_WEBAPP_PATH . 'data/');
//test path with file
$path = FileDataManager::getDataPath('myfile.txt');
$this->assertEqual($path, THINKUP_WEBAPP_PATH . 'data/myfile.txt');
$this->restoreConfigFile();
}
示例9: tearDown
/**
* Tear down
* Destroys Config, Webapp, $_SESSION, $_POST, $_GET, $_REQUEST
*/
public function tearDown()
{
Config::destroyInstance();
Webapp::destroyInstance();
Crawler::destroyInstance();
if (isset($_SESSION)) {
$this->unsetArray($_SESSION);
}
$this->unsetArray($_POST);
$this->unsetArray($_GET);
$this->unsetArray($_REQUEST);
$this->unsetArray($_SERVER);
Loader::unregister();
parent::tearDown();
}
示例10: testGetUnsetDefaultValue
public function testGetUnsetDefaultValue()
{
Config::destroyInstance();
$this->removeConfigFile();
$config = Config::getInstance(array('timezone' => 'America/Los_Angeles'));
$this->assertEqual($config->getValue('app_title_prefix'), '');
$this->assertNotNull($config->getValue('app_title_prefix'));
$this->restoreConfigFile();
}
示例11: testGetConnectString
public function testGetConnectString() {
$this->removeConfigFile();
Config::destroyInstance();
$cfg_values = array("db_host"=>"localhost");
$config = Config::getInstance($cfg_values);
$this->assertEqual(PDODAO::getConnectString($config), "mysql:dbname=;host=localhost");
$this->removeConfigFile();
Config::destroyInstance();
$cfg_values = array("db_type" => "mysql", "db_host"=>"localhost", "db_name" => "thinkup");
$config = Config::getInstance($cfg_values);
$this->assertEqual(PDODAO::getConnectString($config), "mysql:dbname=thinkup;host=localhost");
$this->removeConfigFile();
Config::destroyInstance();
$cfg_values = array("db_host"=>"localhost", "db_name" => "thinkup", "db_port" => "3306");
$config = Config::getInstance($cfg_values);
$this->assertEqual(PDODAO::getConnectString($config), "mysql:dbname=thinkup;host=localhost;port=3306");
$this->removeConfigFile();
Config::destroyInstance();
$cfg_values = array("db_host"=>"localhost", "db_name" => "thinkup", "db_socket" => "/var/mysql");
$config = Config::getInstance($cfg_values);
$this->assertEqual(PDODAO::getConnectString($config),
"mysql:dbname=thinkup;host=localhost;unix_socket=/var/mysql");
$this->restoreConfigFile();
}
示例12: tearDown
public function tearDown()
{
Config::destroyInstance();
parent::tearDown();
}
示例13: testFreshInstallStep3SuccessfulInstall
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'] = "you@example.com";
$_POST['password'] = "asdfadsf123";
$_POST['confirm_password'] = "asdfadsf123";
$_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;
}
示例14: testFreshInstallStep3SuccessfulInstall
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'] = "you@example.com";
$_POST['password'] = "asdfadsf";
$_POST['confirm_password'] = "asdfadsf";
$_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;
}
示例15: testGetInstallerDAONoConfigFile
/**
* Test get InstallerDAO without a config file, override with array of config values
*/
public function testGetInstallerDAONoConfigFile()
{
$this->removeConfigFile();
Config::destroyInstance();
$cfg_values = array("table_prefix" => ThinkUpTestDatabaseHelper::$prefix, "db_host" => "localhost");
$config = Config::getInstance($cfg_values);
$dao = DAOFactory::getDAO('InstallerDAO', $cfg_values);
$this->assertTrue(isset($dao));
$this->assertIsA($dao, 'InstallerMySQLDAO');
$result = $dao->getTables();
$this->assertEqual(sizeof($result), 38);
$this->assertEqual($result[0], $cfg_values["table_prefix"] . 'cookies');
$this->assertEqual($result[1], $cfg_values["table_prefix"] . 'count_history');
$this->restoreConfigFile();
}