Created separate mysql config file for tests

This commit is contained in:
Dmitriy Simushev 2012-09-07 14:08:23 +00:00
parent 0861fd73d2
commit 92019f99a4
3 changed files with 43 additions and 17 deletions

View File

@ -1,7 +1,7 @@
<?php
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/database.php';
require_once dirname(__FILE__) . '/../../../../webim/libs/config.php';
require_once dirname(__FILE__) . '/../database_config.php';
/**
* Test class for Database.
@ -23,22 +23,22 @@ class DatabaseTest extends PHPUnit_Framework_TestCase {
}
public static function setUpBeforeClass() {
global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb, $dbencoding,
$mysqlprefix, $use_persistent_connection, $force_charset_in_connection;
global $db_host, $db_name, $db_user, $db_pass, $tables_prefix,
$db_encoding, $force_charset_in_connection, $use_persistent_connection;
Database::initialize(
$mysqlhost,
$mysqllogin,
$mysqlpass,
$db_host,
$db_user,
$db_pass,
$use_persistent_connection,
$mysqldb,
$mysqlprefix,
$db_name,
$tables_prefix,
$force_charset_in_connection,
$dbencoding
$db_encoding
);
$dbh = new PDO(
"mysql:host={$mysqlhost};dbname={$mysqldb}",
$mysqllogin,
$mysqlpass
"mysql:host={$db_host};dbname={$db_name}",
$db_user,
$db_pass
);
$dbh->exec(
"CREATE TABLE phpunit_test_only " .
@ -48,11 +48,11 @@ class DatabaseTest extends PHPUnit_Framework_TestCase {
}
public static function tearDownAfterClass() {
global $mysqlhost, $mysqllogin, $mysqlpass, $mysqldb;
global $db_host, $db_user, $db_pass, $db_name;
$dbh = new PDO(
"mysql:host={$mysqlhost};dbname={$mysqldb}",
$mysqllogin,
$mysqlpass
"mysql:host={$db_host};dbname={$db_name}",
$db_user,
$db_pass
);
$dbh->exec("DROP TABLE phpunit_test_only");
$dbh = NULL;

View File

@ -1,8 +1,8 @@
<?php
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/settings.php';
require_once dirname(__FILE__) . '/../../../../webim/libs/config.php';
require_once dirname(__FILE__) . '/../../../../webim/libs/classes/database.php';
require_once dirname(__FILE__) . '/../database_config.php';
/**
* Test class for Settings.
@ -11,6 +11,18 @@ require_once dirname(__FILE__) . '/../../../../webim/libs/classes/database.php';
class SettingsTest extends PHPUnit_Framework_TestCase {
public static function setUpBeforeClass() {
global $db_host, $db_name, $db_user, $db_pass, $tables_prefix,
$db_encoding, $force_charset_in_connection, $use_persistent_connection;
Database::initialize(
$db_host,
$db_user,
$db_pass,
$use_persistent_connection,
$db_name,
$tables_prefix,
$force_charset_in_connection,
$db_encoding
);
$db = Database::getInstance();
$db->query(
"INSERT INTO {chatconfig} (vckey, vcvalue) " .
@ -25,6 +37,7 @@ class SettingsTest extends PHPUnit_Framework_TestCase {
"DELETE FROM {chatconfig} WHERE vckey = ? OR vckey = ?",
array('some_test_key', 'some_another_test_key')
);
Database::destroy();
}
public function testGet() {

View File

@ -0,0 +1,13 @@
<?php
$db_host = "";
$db_user = "";
$db_pass = "";
$db_name = "";
$tables_prefix = "";
$db_encoding = "utf8";
$force_charset_in_connection = true;
$use_persistent_connection = false;
?>