svn: /php/php-src/ branches/PHP_5_3/ext/mysql/tests/mysql_connect.phpt trunk/ext/mysql/tests/mysql_connect.phpt
| From: | Ulf Wendel | Date: | Wed, 09 Sep 2009 17:16:24 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/mysql/tests/mysql_connect.phpt trunk/ext/mysql/tests/mysql_connect.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-60358@lists.php.net to get a copy of this message | ||
uw Wed, 09 Sep 2009 17:16:24 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=288204
Log:
Some extra test coverage for http://bugs.php.net/bug.php?id=48754 .
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_connect.phpt
U php/php-src/trunk/ext/mysql/tests/mysql_connect.phpt
Modified: php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_connect.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_connect.phpt 2009-09-09 17:10:29 UTC (rev
288203)
+++ php/php-src/branches/PHP_5_3/ext/mysql/tests/mysql_connect.phpt 2009-09-09 17:16:24 UTC (rev
288204)
@@ -20,17 +20,23 @@
mysql_close($link);
+if (!$link = mysql_connect($myhost, $user, $passwd, true))
+ printf("[003] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s,
port=%s, socket=%s\n",
+ $host, $myhost, $user, $db, $port, $socket);
+
+mysql_close();
+
if ($link = mysql_connect($myhost, $user . 'unknown_really', $passwd .
'non_empty', true))
- printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty,
dbname=%s, port=%s, socket=%s\n",
+ printf("[004] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty,
dbname=%s, port=%s, socket=%s\n",
$host, $myhost, $user . 'unknown_really', $db, $port, $socket);
if (false !== $link)
-printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
+printf("[005] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
// Run the following tests without an anoynmous MySQL user and use a password for the test user!
ini_set('mysql.default_socket', $socket);
if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
- printf("[005] Usage of mysql.default_socket failed\n");
+ printf("[006] Usage of mysql.default_socket failed\n");
} else {
mysql_close($link);
}
@@ -39,42 +45,49 @@
ini_set('mysql.default_port', $port);
if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
- printf("[006] Usage of mysql.default_port failed\n");
+ printf("[007] Usage of mysql.default_port failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_password', $passwd);
if (!is_resource($link = mysql_connect($myhost, $user))) {
- printf("[007] Usage of mysql.default_password failed\n");
+ printf("[008] Usage of mysql.default_password failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_user', $user);
if (!is_resource($link = mysql_connect($myhost))) {
- printf("[008] Usage of mysql.default_user failed\n");
+ printf("[009] Usage of mysql.default_user failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_host', $myhost);
if (!is_resource($link = mysql_connect())) {
- printf("[009] Usage of mysql.default_host failed\n") ;
+ printf("[010] Usage of mysql.default_host failed\n") ;
} else {
mysql_close($link);
}
+ if (!is_resource($link = mysql_connect()) || !is_resource($link2 = mysql_connect())) {
+ printf("[011] Usage of mysql.default_host failed\n") ;
+ } else {
+ mysql_close();
+ mysql_close($link2);
+ }
+
if (!stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'netware')) {
ini_set('mysql.default_port', -1);
if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port))) {
if (!is_resource($link = mysql_connect())) {
- printf("[010] Usage of env MYSQL_TCP_PORT failed\n") ;
+ printf("[012] Usage of env MYSQL_TCP_PORT failed\n") ;
} else {
mysql_close($link);
}
} else if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port + 1))) {
if (!is_resource($link = mysql_connect())) {
- printf("[011] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
+ printf("[013] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
mysql_close($link);
}
}
Modified: php/php-src/trunk/ext/mysql/tests/mysql_connect.phpt
===================================================================
--- php/php-src/trunk/ext/mysql/tests/mysql_connect.phpt 2009-09-09 17:10:29 UTC (rev 288203)
+++ php/php-src/trunk/ext/mysql/tests/mysql_connect.phpt 2009-09-09 17:16:24 UTC (rev 288204)
@@ -20,17 +20,23 @@
mysql_close($link);
+if (!$link = mysql_connect($myhost, $user, $passwd, true))
+ printf("[003] Cannot connect to the server using host=%s/%s, user=%s, passwd=***, dbname=%s,
port=%s, socket=%s\n",
+ $host, $myhost, $user, $db, $port, $socket);
+
+mysql_close();
+
if ($link = mysql_connect($myhost, $user . 'unknown_really', $passwd .
'non_empty', true))
- printf("[003] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty,
dbname=%s, port=%s, socket=%s\n",
+ printf("[004] Can connect to the server using host=%s/%s, user=%s, passwd=***non_empty,
dbname=%s, port=%s, socket=%s\n",
$host, $myhost, $user . 'unknown_really', $db, $port, $socket);
if (false !== $link)
-printf("[004] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
+printf("[005] Expecting boolean/false, got %s/%s\n", gettype($link), $link);
// Run the following tests without an anoynmous MySQL user and use a password for the test user!
ini_set('mysql.default_socket', $socket);
if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
- printf("[005] Usage of mysql.default_socket failed\n");
+ printf("[006] Usage of mysql.default_socket failed\n");
} else {
mysql_close($link);
}
@@ -39,42 +45,49 @@
ini_set('mysql.default_port', $port);
if (!is_resource($link = mysql_connect($host, $user, $passwd, true))) {
- printf("[006] Usage of mysql.default_port failed\n");
+ printf("[007] Usage of mysql.default_port failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_password', $passwd);
if (!is_resource($link = mysql_connect($myhost, $user))) {
- printf("[007] Usage of mysql.default_password failed\n");
+ printf("[008] Usage of mysql.default_password failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_user', $user);
if (!is_resource($link = mysql_connect($myhost))) {
- printf("[008] Usage of mysql.default_user failed\n");
+ printf("[009] Usage of mysql.default_user failed\n");
} else {
mysql_close($link);
}
ini_set('mysql.default_host', $myhost);
if (!is_resource($link = mysql_connect())) {
- printf("[009] Usage of mysql.default_host failed\n") ;
+ printf("[010] Usage of mysql.default_host failed\n") ;
} else {
mysql_close($link);
}
+ if (!is_resource($link = mysql_connect()) || !is_resource($link2 = mysql_connect())) {
+ printf("[011] Usage of mysql.default_host failed\n") ;
+ } else {
+ mysql_close();
+ mysql_close($link2);
+ }
+
if (!stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'netware')) {
ini_set('mysql.default_port', -1);
if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port))) {
if (!is_resource($link = mysql_connect())) {
- printf("[010] Usage of env MYSQL_TCP_PORT failed\n") ;
+ printf("[012] Usage of env MYSQL_TCP_PORT failed\n") ;
} else {
mysql_close($link);
}
} else if (putenv(sprintf('MYSQL_TCP_PORT=%d', $port + 1))) {
if (!is_resource($link = mysql_connect())) {
- printf("[011] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
+ printf("[013] Usage of env MYSQL_TCP_PORT=%d should have failed\n", $port + 1) ;
mysql_close($link);
}
}