mirror of
				https://github.com/Mibew/java.git
				synced 2025-10-31 18:41:09 +03:00 
			
		
		
		
	Created separate mysql config file for tests
This commit is contained in:
		
							parent
							
								
									0861fd73d2
								
							
						
					
					
						commit
						92019f99a4
					
				| @ -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; | ||||
|  | ||||
| @ -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() { | ||||
|  | ||||
							
								
								
									
										13
									
								
								src/messenger/tests/server_side/webim/database_config.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								src/messenger/tests/server_side/webim/database_config.php
									
									
									
									
									
										Normal 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; | ||||
| 
 | ||||
| ?>
 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user