summaryrefslogtreecommitdiff
path: root/ext/mysql/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/mysql/tests')
-rw-r--r--ext/mysql/tests/bug51242.phpt38
-rwxr-xr-xext/mysql/tests/connect.inc4
-rw-r--r--ext/mysql/tests/mysql_constants.phpt2
-rw-r--r--ext/mysql/tests/mysql_fetch_array.phpt7
-rw-r--r--ext/mysql/tests/mysql_fetch_field.phpt13
-rw-r--r--ext/mysql/tests/mysql_query_load_data_openbasedir.phpt1
-rw-r--r--ext/mysql/tests/skipifnotmysqlnd.inc5
7 files changed, 62 insertions, 8 deletions
diff --git a/ext/mysql/tests/bug51242.phpt b/ext/mysql/tests/bug51242.phpt
new file mode 100644
index 000000000..9b62cdb4c
--- /dev/null
+++ b/ext/mysql/tests/bug51242.phpt
@@ -0,0 +1,38 @@
+--TEST--
+Bug #51242 (Empty mysql.default_port does not default to 3306 anymore, but 0)
+--INI--
+mysql.default_port=
+mysql.default_socket=/this/does/not/really/need/to/exist
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifnotmysqlnd.inc');
+
+// Specific to this bug: we need to be able to connect via TCP. We'll use
+// 127.0.0.1:3306 as a (hopefully) moderately sensible default if the hostname
+// is actually specified as localhost.
+if ($host == 'localhost') {
+ $host = '127.0.0.1';
+}
+
+if (!@mysql_connect("$host:3306", $user, $passwd)) {
+ die("skip mysql not available at $host:3306");
+}
+?>
+--FILE--
+<?php
+require_once('connect.inc');
+
+if ($host == 'localhost') {
+ $host = '127.0.0.1';
+}
+
+if ($link = my_mysql_connect($host, $user, $passwd, $db, null, $socket)) {
+ var_dump($link);
+} else {
+ printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
+ $host, $user, $db, null, $socket);
+}
+?>
+--EXPECTF--
+resource(%d) of type (mysql link)
diff --git a/ext/mysql/tests/connect.inc b/ext/mysql/tests/connect.inc
index b5cc03ecb..97fed4214 100755
--- a/ext/mysql/tests/connect.inc
+++ b/ext/mysql/tests/connect.inc
@@ -69,7 +69,9 @@ $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;
$connect_flags = getenv("MYSQL_TEST_CONNECT_FLAGS") ? (int)getenv("MYSQL_TEST_CONNECT_FLAGS") : 0;
-
+if ($socket) {
+ ini_set('mysql.default_user', $socket);
+}
/* Development setting: test experimal features and/or feature requests that never worked before? */
$TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1))) ?
((1 == getenv("MYSQL_TEST_EXPERIMENTAL")) ? true : false) :
diff --git a/ext/mysql/tests/mysql_constants.phpt b/ext/mysql/tests/mysql_constants.phpt
index e88e6556f..134610020 100644
--- a/ext/mysql/tests/mysql_constants.phpt
+++ b/ext/mysql/tests/mysql_constants.phpt
@@ -38,7 +38,7 @@ $unexpected_constants = array();
foreach ($constants as $group => $consts) {
foreach ($consts as $name => $value) {
- if (stristr($name, 'mysql') && !stristr($name, 'mysqli')) {
+ if (stristr($name, 'mysql') && !preg_match("/^mysql([^_]+)_/iu", $name)) {
$name = strtoupper($name);
if (isset($expected_constants[$name])) {
unset($expected_constants[$name]);
diff --git a/ext/mysql/tests/mysql_fetch_array.phpt b/ext/mysql/tests/mysql_fetch_array.phpt
index 635e6d109..362cf99dd 100644
--- a/ext/mysql/tests/mysql_fetch_array.phpt
+++ b/ext/mysql/tests/mysql_fetch_array.phpt
@@ -50,7 +50,7 @@ mysql_free_result($res);
if (!$res = mysql_query("SELECT 1 AS a, 2 AS b, 3 AS c, 4 AS C", $link)) {
printf("[012] Cannot run query, [%d] %s\n",
mysql_errno($link), $mysql_error($link));
-exit(1);
+ exit(1);
}
do {
@@ -76,7 +76,6 @@ function func_mysql_fetch_array($link, $engine, $sql_type, $sql_value, $php_valu
}
if (!mysql_query($sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine), $link)) {
- print $sql;
// don't bail, engine might not support the datatype
return false;
}
@@ -225,11 +224,11 @@ func_mysql_fetch_array($link, $engine, "CHAR(255)", $string255, $string255, 550
func_mysql_fetch_array($link, $engine, "CHAR(1) NOT NULL", "a", "a", 560);
func_mysql_fetch_array($link, $engine, "CHAR(1)", NULL, NULL, 570);
-$string65k = func_mysql_fetch_array_make_string(65535);
+$string65k = func_mysql_fetch_array_make_string(65400);
func_mysql_fetch_array($link, $engine, "VARCHAR(1)", "a", "a", 580);
func_mysql_fetch_array($link, $engine, "VARCHAR(255)", $string255, $string255, 590);
-func_mysql_fetch_array($link, $engine, "VARCHAR(65635)", $string65k, $string65k, 600);
+func_mysql_fetch_array($link, $engine, "VARCHAR(65400)", $string65k, $string65k, 600);
func_mysql_fetch_array($link, $engine, "VARCHAR(1) NOT NULL", "a", "a", 610);
func_mysql_fetch_array($link, $engine, "VARCHAR(1)", NULL, NULL, 620);
diff --git a/ext/mysql/tests/mysql_fetch_field.phpt b/ext/mysql/tests/mysql_fetch_field.phpt
index 65c44edc5..ef0327908 100644
--- a/ext/mysql/tests/mysql_fetch_field.phpt
+++ b/ext/mysql/tests/mysql_fetch_field.phpt
@@ -51,6 +51,7 @@ require_once('skipifconnectfailure.inc');
'BIT' => array(1, 'int'),
'TINYINT' => array(1, 'int'),
'BOOL' => array('true', 'int'),
+ 'BOOL' => array(1, 'int'),
'SMALLINT' => array(32767, 'int'),
'MEDIUMINT' => array(8388607, 'int'),
'INT' => array(100, 'int'),
@@ -86,7 +87,17 @@ require_once('skipifconnectfailure.inc');
// server and/or engine might not support the data type
continue;
}
- if (!mysql_query(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $type_desc[0]), $link)) {
+
+ if (is_string($type_desc[0]))
+ $insert = sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $type_desc[0]);
+ else
+ $insert = sprintf("INSERT INTO test(id, label) VALUES (1, %s)", $type_desc[0]);
+
+ if (!mysql_query($insert, $link)) {
+ if (1366 == mysql_errno($link)) {
+ /* Strict SQL mode - 1366, Incorrect integer value: 'true' for column 'label' at row 1 */
+ continue;
+ }
printf("[009/%s] [%d] %s\n", $type_name, mysql_errno($link), mysql_error($link));
continue;
}
diff --git a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
index a257f5fb8..ff62f4227 100644
--- a/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
+++ b/ext/mysql/tests/mysql_query_load_data_openbasedir.phpt
@@ -26,7 +26,6 @@ if ($socket == "" && $host != NULL && $host != 'localhost' && $host != '.') {
}
?>
--INI--
-safe_mode=0
open_basedir="."
--FILE--
<?php
diff --git a/ext/mysql/tests/skipifnotmysqlnd.inc b/ext/mysql/tests/skipifnotmysqlnd.inc
new file mode 100644
index 000000000..9cccdc7bf
--- /dev/null
+++ b/ext/mysql/tests/skipifnotmysqlnd.inc
@@ -0,0 +1,5 @@
+<?php
+if (strpos(mysql_get_client_info(), 'mysqlnd') === false) {
+ die('skip mysqlnd extension not available');
+}
+?>