uw                                       Fri, 25 Sep 2009 10:54:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=288745

Log:
Replacing MYSQL_TEST_COMPRESS env var with more generic 
MYSQL_TEST_CONNECT_FLAGS to be able to test all connection flags. Fixing some 
test.

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc
    U   php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_errno.phpt
    U   
php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
    U   php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_max_links.phpt
    U   php/php-src/trunk/ext/mysqli/tests/connect.inc
    U   php/php-src/trunk/ext/mysqli/tests/mysqli_connect_errno.phpt
    U   php/php-src/trunk/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
    U   php/php-src/trunk/ext/mysqli/tests/mysqli_max_links.phpt

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/connect.inc	2009-09-25 10:54:16 UTC (rev 288745)
@@ -16,7 +16,7 @@
 	$engine    = getenv("MYSQL_TEST_ENGINE")   ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
 	$socket    = getenv("MYSQL_TEST_SOCKET")   ? getenv("MYSQL_TEST_SOCKET") : null;
 	$skip_on_connect_failure  = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
-	$test_compress = getenv("MYSQL_TEST_COMPRESS") ? (boolean)getenv("MYSQL_TEST_COMPRESS") : false;
+	$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;

 	/* Development setting: test experimal features and/or feature requests that never worked before? */
 	$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
@@ -51,6 +51,7 @@
 			/* unknown */
 			$MYSQLND_VERSION = -1;
 		}
+
 	}

 	if (!function_exists('sys_get_temp_dir')) {
@@ -76,17 +77,17 @@
 	/**
 	* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
 	*
-	* @param compress mixed: -1 => use global default, false -> no compression, true -> compression
+	* @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
 	*/
-	function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $compress = -1) {
-		global $test_compress;
+	function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+		global $connect_flags;

-		if (-1 == $compress)
-			$compress = $test_compress;
+		$flags = ($enable_env_flags) ? $connect_flags : false;

-		if ($compress) {
+		if ($flags !== false) {
 			$link = mysqli_init();
-			mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 0 & MYSQLI_CLIENT_COMPRESS);
+			if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
+				$link = false;
 		} else {
 			$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 		}
@@ -97,27 +98,26 @@
 	/**
 	* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
 	*
-	* @param compress mixed: -1 => use global default, false -> no compression, true -> compression
+	* @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
 	*/
-	function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $compress = -1) {
-		global $test_compress;
+	function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
+		global $connect_flags;

-		if (-1 == $compress)
-			$compress = $test_compress;
+		if ($enable_env_flags)
+			$flags & $connect_flags;

-		return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags & MYSQLI_CLIENT_COMPRESS);
+		return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
 	}

 	class my_mysqli extends mysqli {
-		public function __construct($host, $user, $passwd, $db, $port, $socket, $compress = -1) {
-			global $test_compress;
+		public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+			global $connect_flags;

-			if (-1 == $compress)
-				$compress = $test_compress;
+			$flags = ($enable_env_flags) ? $connect_flags : false;

-			if ($compress) {
+			if ($flags !== false) {
 				parent::init();
-				$this->real_connect($host, $user, $passwd, $db, $port, $socket, 0 & MYSQLI_CLIENT_COMPRESS);
+				$this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
 			} else {
 				parent::__construct($host, $user, $passwd, $db, $port, $socket);
 			}

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_errno.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_errno.phpt	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_errno.phpt	2009-09-25 10:54:16 UTC (rev 288745)
@@ -29,7 +29,7 @@
 	$link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket);
 	if (false !== $link)
 		printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n",
-			$host, $user . 'unknown_really', $db, $port, $socket, gettype($link), $link);
+			$host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true));

 	if (0 === ($tmp = mysqli_connect_errno()))
 		printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp);

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt	2009-09-25 10:54:16 UTC (rev 288745)
@@ -28,12 +28,12 @@
 	var_dump(mysqli_connect_errno());

 	print "3) bail\n";
-	if (false !== ($link = my_mysqli_connect($myhost))) {
+	if (false !== ($link = mysqli_connect($myhost))) {
 		printf("[003] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
 	}

 	print "4) be quiet\n";
-	if (false !== ($link = @my_mysqli_connect($myhost))) {
+	if (false !== ($link = @mysqli_connect($myhost))) {
 		printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
 	}
 	var_dump(mysqli_connect_error());
@@ -50,7 +50,7 @@
 int(200%d)
 3) bail

-Warning: my_mysqli_connect(): (HY000/200%d): %s
+Warning: mysqli_connect(): (HY000/200%d): %s
 4) be quiet
 %s(%d) "%s"
 int(200%d)

Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_max_links.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_max_links.phpt	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_max_links.phpt	2009-09-25 10:54:16 UTC (rev 288745)
@@ -44,15 +44,15 @@
 bool(true)
 int(1)

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d


Modified: php/php-src/trunk/ext/mysqli/tests/connect.inc
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/connect.inc	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/trunk/ext/mysqli/tests/connect.inc	2009-09-25 10:54:16 UTC (rev 288745)
@@ -16,7 +16,7 @@
 	$engine    = getenv("MYSQL_TEST_ENGINE")   ? getenv("MYSQL_TEST_ENGINE") : "MyISAM";
 	$socket    = getenv("MYSQL_TEST_SOCKET")   ? getenv("MYSQL_TEST_SOCKET") : null;
 	$skip_on_connect_failure  = getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") ? getenv("MYSQL_TEST_SKIP_CONNECT_FAILURE") : true;
-	$test_compress = getenv("MYSQL_TEST_COMPRESS") ? (boolean)getenv("MYSQL_TEST_COMPRESS") : false;
+	$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;

 	/* Development setting: test experimal features and/or feature requests that never worked before? */
 	$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
@@ -51,6 +51,7 @@
 			/* unknown */
 			$MYSQLND_VERSION = -1;
 		}
+
 	}

 	if (!function_exists('sys_get_temp_dir')) {
@@ -76,17 +77,17 @@
 	/**
 	* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
 	*
-	* @param compress mixed: -1 => use global default, false -> no compression, true -> compression
+	* @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)?
 	*/
-	function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $compress = -1) {
-		global $test_compress;
+	function my_mysqli_connect($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+		global $connect_flags;

-		if (-1 == $compress)
-			$compress = $test_compress;
+		$flags = ($enable_env_flags) ? $connect_flags : false;

-		if ($compress) {
+		if ($flags !== false) {
 			$link = mysqli_init();
-			mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, 0 & MYSQLI_CLIENT_COMPRESS);
+			if (!mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags))
+				$link = false;
 		} else {
 			$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 		}
@@ -97,27 +98,26 @@
 	/**
 	* Whenever possible, please use this wrapper to make testing ot MYSQLI_CLIENT_COMPRESS (and potentially SSL) possible
 	*
-	* @param compress mixed: -1 => use global default, false -> no compression, true -> compression
+	* @param enable_env_flags Enable setting of connection flags through env(MYSQL_TEST_CONNECT_FLAGS)
 	*/
-	function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $compress = -1) {
-		global $test_compress;
+	function my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags = 0, $enable_env_flags = true) {
+		global $connect_flags;

-		if (-1 == $compress)
-			$compress = $test_compress;
+		if ($enable_env_flags)
+			$flags & $connect_flags;

-		return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags & MYSQLI_CLIENT_COMPRESS);
+		return mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags);
 	}

 	class my_mysqli extends mysqli {
-		public function __construct($host, $user, $passwd, $db, $port, $socket, $compress = -1) {
-			global $test_compress;
+		public function __construct($host, $user, $passwd, $db, $port, $socket, $enable_env_flags = true) {
+			global $connect_flags;

-			if (-1 == $compress)
-				$compress = $test_compress;
+			$flags = ($enable_env_flags) ? $connect_flags : false;

-			if ($compress) {
+			if ($flags !== false) {
 				parent::init();
-				$this->real_connect($host, $user, $passwd, $db, $port, $socket, 0 & MYSQLI_CLIENT_COMPRESS);
+				$this->real_connect($host, $user, $passwd, $db, $port, $socket, $flags);
 			} else {
 				parent::__construct($host, $user, $passwd, $db, $port, $socket);
 			}

Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_connect_errno.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_connect_errno.phpt	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_connect_errno.phpt	2009-09-25 10:54:16 UTC (rev 288745)
@@ -29,7 +29,7 @@
 	$link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket);
 	if (false !== $link)
 		printf("[004] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s, expecting boolean/false, got %s/%s\n",
-			$host, $user . 'unknown_really', $db, $port, $socket, gettype($link), $link);
+			$host, $user . 'unknown_really', $db, $port, $socket, gettype($link), var_export($link, true));

 	if (0 === ($tmp = mysqli_connect_errno()))
 		printf("[005] Expecting integer/any non-zero, got %s/%s\n", gettype($tmp), $tmp);

Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_connect_oo_warnings.phpt	2009-09-25 10:54:16 UTC (rev 288745)
@@ -28,12 +28,12 @@
 	var_dump(mysqli_connect_errno());

 	print "3) bail\n";
-	if (false !== ($link = my_mysqli_connect($myhost))) {
+	if (false !== ($link = mysqli_connect($myhost))) {
 		printf("[003] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
 	}

 	print "4) be quiet\n";
-	if (false !== ($link = @my_mysqli_connect($myhost))) {
+	if (false !== ($link = @mysqli_connect($myhost))) {
 		printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
 	}
 	var_dump(mysqli_connect_error());
@@ -50,7 +50,7 @@
 int(200%d)
 3) bail

-Warning: my_mysqli_connect(): (HY000/200%d): %s
+Warning: mysqli_connect(): (HY000/200%d): %s
 4) be quiet
 %s(%d) "%s"
 int(200%d)

Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_max_links.phpt
===================================================================
--- php/php-src/trunk/ext/mysqli/tests/mysqli_max_links.phpt	2009-09-25 10:53:58 UTC (rev 288744)
+++ php/php-src/trunk/ext/mysqli/tests/mysqli_max_links.phpt	2009-09-25 10:54:16 UTC (rev 288745)
@@ -44,15 +44,15 @@
 bool(true)
 int(1)

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

-Warning: mysqli_connect(): Too many open links (1) in %s on line %d
+Warning: mysqli_%sonnect(): Too many open links (1) in %s on line %d

 Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in %s on line %d

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to