From 2dd1b35a859c31e490ebc627bc49f61366aac5a2 Mon Sep 17 00:00:00 2001 From: Ulf Wendel Date: Wed, 10 Oct 2007 10:49:00 +0000 Subject: [PATCH] Commiting changes into HEAD = synching with 5_3 --- ext/mysqli/tests/bug29311.phpt | 22 ++-- ext/mysqli/tests/bug33263.phpt | 15 ++- ext/mysqli/tests/mysqli_affected_rows_oo.phpt | 8 +- ext/mysqli/tests/mysqli_autocommit.phpt | 22 ++-- ext/mysqli/tests/mysqli_autocommit_oo.phpt | 3 +- .../tests/mysqli_class_mysqli_interface.phpt | 6 +- .../tests/mysqli_class_mysqli_reflection.phpt | 34 +---- ext/mysqli/tests/mysqli_connect.phpt | 6 + ext/mysqli/tests/mysqli_fetch_all.phpt | 120 +++++++++--------- ext/mysqli/tests/mysqli_fetch_all_oo.phpt | 4 +- ext/mysqli/tests/mysqli_fetch_assoc.phpt | 64 +++++++++- ext/mysqli/tests/mysqli_fetch_object.phpt | 6 +- 12 files changed, 176 insertions(+), 134 deletions(-) diff --git a/ext/mysqli/tests/bug29311.phpt b/ext/mysqli/tests/bug29311.phpt index 74cd2ec886..0c70f83557 100644 --- a/ext/mysqli/tests/bug29311.phpt +++ b/ext/mysqli/tests/bug29311.phpt @@ -1,14 +1,14 @@ --TEST-- constructor test --SKIPIF-- - --FILE-- connect($host, $user, $passwd, $db, $port, $socket); @@ -28,24 +28,24 @@ require_once('skipifconnectfailure.inc'); /* class 3 has no constructor */ class mysql3 extends mysqli { - + } - $foo[0] = new mysql1(); - $foo[1] = new mysql2(); + $foo[0] = new mysql1(); + $foo[1] = new mysql2(); $foo[2] = new mysql3($host, $user, $passwd, $db, $port, $socket); for ($i=0; $i < 3; $i++) { if (($result = $foo[$i]->query("SELECT DATABASE()"))) { $row = $result->fetch_row(); - printf("%d: %s\n", $i, $row[0]); + if ($row[0] != $db) + printf("%d: %s\n", $i, $row[0]); $result->close(); } $foo[$i]->close(); } + print "done!"; ?> --EXPECTF-- -0: test -1: test -2: test +done! \ No newline at end of file diff --git a/ext/mysqli/tests/bug33263.phpt b/ext/mysqli/tests/bug33263.phpt index 017e098443..4f2a37c865 100644 --- a/ext/mysqli/tests/bug33263.phpt +++ b/ext/mysqli/tests/bug33263.phpt @@ -1,8 +1,8 @@ --TEST-- -Bug #33263 (mysqli_real_connect in __construct) +Bug #33263 (mysqli_real_connect in __construct) --SKIPIF-- - @@ -23,13 +23,16 @@ require_once('skipifconnectfailure.inc'); $stmt = $mysql->prepare("SELECT DATABASE()"); $stmt->execute(); - $stmt->bind_result($db); + $stmt->bind_result($database); $stmt->fetch(); $stmt->close(); - var_dump($db); + if ($database != $db) + printf("[001] Expecting '%s' got %s/'%s'.\n", + gettype($database), $database); $mysql->close(); + print "done!"; ?> --EXPECTF-- -%s(4) "test" +done! \ No newline at end of file diff --git a/ext/mysqli/tests/mysqli_affected_rows_oo.phpt b/ext/mysqli/tests/mysqli_affected_rows_oo.phpt index 0d8670e938..4d82981baf 100644 --- a/ext/mysqli/tests/mysqli_affected_rows_oo.phpt +++ b/ext/mysqli/tests/mysqli_affected_rows_oo.phpt @@ -1,7 +1,7 @@ --TEST-- mysqli->affected_rows --SKIPIF-- -affected_rows affected_rows)) + printf("[000a] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); + if (!$mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket)) { printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket); } if (0 !== ($tmp = $mysqli->affected_rows)) - printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); + printf("[002] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp); if (!$mysqli->query('DROP TABLE IF EXISTS test')) printf("[003] [%d] %s\n", $mysqli->errno, $mysqli->error); diff --git a/ext/mysqli/tests/mysqli_autocommit.phpt b/ext/mysqli/tests/mysqli_autocommit.phpt index a6b69c6379..1bffb53ca7 100644 --- a/ext/mysqli/tests/mysqli_autocommit.phpt +++ b/ext/mysqli/tests/mysqli_autocommit.phpt @@ -2,28 +2,26 @@ mysqli_autocommit() --SKIPIF-- --FILE-- diff --git a/ext/mysqli/tests/mysqli_autocommit_oo.phpt b/ext/mysqli/tests/mysqli_autocommit_oo.phpt index 241f08dc31..006a5d4bab 100644 --- a/ext/mysqli/tests/mysqli_autocommit_oo.phpt +++ b/ext/mysqli/tests/mysqli_autocommit_oo.phpt @@ -2,9 +2,10 @@ mysqli->autocommit() --SKIPIF-- true, 'select_db' => true, 'set_charset' => true, - 'set_local_infile_default' => true, - 'set_local_infile_handler' => true, 'set_opt' => true, 'stat' => true, 'stmt_init' => true, @@ -93,6 +91,8 @@ require_once('skipifconnectfailure.inc'); if (function_exists('mysqli_ssl_set')) $expected_methods['ssl_set'] = true; + $expected_methods['set_local_infile_default'] = true; + $expected_methods['set_local_infile_handler'] = true; } /* we should add ruled when to expect them */ @@ -305,4 +305,4 @@ setting mysqli->unknown, mysqli_unknown = 'friday' Access hidden properties for MYSLQI_STATUS_INITIALIZED (TODO documentation): mysqli->connect_error = ''/unicode (''/unicode) mysqli->connect_errno = '0'/integer ('0'/integer) -done! \ No newline at end of file +done! diff --git a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt index 4f3243132f..68ae1a725f 100644 --- a/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt +++ b/ext/mysqli/tests/mysqli_class_mysqli_reflection.phpt @@ -551,38 +551,6 @@ Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 -Inspecting method 'set_local_infile_default' -isFinal: no -isAbstract: no -isPublic: yes -isPrivate: no -isProtected: no -isStatic: no -isConstructor: no -isDestructor: no -isInternal: yes -isUserDefined: no -returnsReference: no -Modifiers: 256 -Number of Parameters: 0 -Number of Required Parameters: 0 - -Inspecting method 'set_local_infile_handler' -isFinal: no -isAbstract: no -isPublic: yes -isPrivate: no -isProtected: no -isStatic: no -isConstructor: no -isDestructor: no -isInternal: yes -isUserDefined: no -returnsReference: no -Modifiers: 256 -Number of Parameters: 0 -Number of Required Parameters: 0 - Inspecting method 'set_opt' isFinal: no isAbstract: no @@ -678,4 +646,4 @@ returnsReference: no Modifiers: 256 Number of Parameters: 0 Number of Required Parameters: 0 -done! \ No newline at end of file +done! diff --git a/ext/mysqli/tests/mysqli_connect.phpt b/ext/mysqli/tests/mysqli_connect.phpt index d5b69d0c23..ebddca94b7 100644 --- a/ext/mysqli/tests/mysqli_connect.phpt +++ b/ext/mysqli/tests/mysqli_connect.phpt @@ -135,6 +135,12 @@ mysqli_connect() mysqli_free_result($res); mysqli_close($link); } + + ini_set('mysqli.default_host', 'p:'); + if (is_object($link = @mysqli_connect())) { + printf("[024] Usage of mysqli.default_host=p: did not fail\n") ; + mysqli_close($link); + } } print "done!"; diff --git a/ext/mysqli/tests/mysqli_fetch_all.phpt b/ext/mysqli/tests/mysqli_fetch_all.phpt index a41444c848..f93d204a67 100644 --- a/ext/mysqli/tests/mysqli_fetch_all.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all.phpt @@ -93,67 +93,67 @@ if (!function_exists('mysqli_fetch_all')) function func_mysqli_fetch_all($link, $engine, $sql_type, $sql_value, $php_value, $offset, $regexp_comparison = NULL) { - if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { - printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { - print $sql; - // don't bail, engine might not support the datatype - return false; - } - - if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { - printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!is_null($php_value)) { - if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { - printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); - return false; - } else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) { - printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); - return false; - } - } - - if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { - printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link)); - return false; - } - - if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) { - printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link)); - return false; - } - $row = $tmp[0]; - - $fields = mysqli_fetch_fields($res); - - if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) { - - if ($regexp_comparison && !$skip) { - if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { - printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, $regexp_comparison, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); - return false; - } - } else { - if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { - printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, - gettype($php_value), $php_value, - gettype($row[1]), $row[1], - gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); - return false; - } + if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) { + printf("[%04d] [%d] %s\n", $offset, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!mysqli_query($link, $sql = sprintf("CREATE TABLE test(id INT NOT NULL, label %s, PRIMARY KEY(id)) ENGINE = %s", $sql_type, $engine))) { + print $sql; + // don't bail, engine might not support the datatype + return false; + } + + if (is_null($php_value) && !mysqli_query($link, $sql = sprintf("INSERT INTO test(id, label) VALUES (1, NULL)"))) { + printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!is_null($php_value)) { + if (is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%d')", $sql_value))) { + printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; + } else if (!is_int($sql_value) && !mysqli_query($link, sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $sql_value))) { + printf("[%04d] [%d] %s\n", $offset + 1, mysqli_errno($link), mysqli_error($link)); + return false; } - } + } + + if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { + printf("[%04d] [%d] %s\n", $offset + 2, mysqli_errno($link), mysqli_error($link)); + return false; + } + + if (!$tmp = mysqli_fetch_all($res, MYSQLI_BOTH)) { + printf("[%04d] [%d] %s\n", $offset + 3, mysqli_errno($link), mysqli_error($link)); + return false; + } + $row = $tmp[0]; + + $fields = mysqli_fetch_fields($res); + + if (!(gettype($php_value)=="unicode" && ($fields[1]->flags & 128))) { + + if ($regexp_comparison) { + if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) { + printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, $regexp_comparison, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); + return false; + } + } else { + if (($row['label'] !== $php_value) || ($row[1] != $php_value)) { + printf("[%04d] Expecting %s/%s, got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4, + gettype($php_value), $php_value, + gettype($row[1]), $row[1], + gettype($row['label']), $row['label'], mysqli_errno($link), mysqli_error($link)); + return false; + } + } + } - return true; + return true; } function func_mysqli_fetch_array_make_string($len) { @@ -558,4 +558,4 @@ array(1) { Warning: mysqli_fetch_all(): Mode can be only MYSQLI_FETCH_NUM, MYSQLI_FETCH_ASSOC or MYSQLI_FETCH_BOTH in %s on line %d Warning: mysqli_fetch_array(): Couldn't fetch mysqli_result in %s on line %d -done! \ No newline at end of file +done! diff --git a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt index eed117f6fd..fcbc52e782 100644 --- a/ext/mysqli/tests/mysqli_fetch_all_oo.phpt +++ b/ext/mysqli/tests/mysqli_fetch_all_oo.phpt @@ -214,12 +214,12 @@ if (!function_exists('mysqli_fetch_all')) func_mysqli_fetch_all_oo($link, $engine, "DECIMAL(10,2)", NULL, NULL, 400); // don't care about date() strict TZ warnings... - $date = date('Y-m-d'); + $date = @date('Y-m-d'); func_mysqli_fetch_all_oo($link, $engine, "DATE", $date, $date, 410); func_mysqli_fetch_all_oo($link, $engine, "DATE NOT NULL", $date, $date, 420); func_mysqli_fetch_all_oo($link, $engine, "DATE", NULL, NULL, 430); - $datetime = date('Y-m-d H:i:s'); + $datetime = @date('Y-m-d H:i:s'); func_mysqli_fetch_all_oo($link, $engine, "DATETIME", $datetime, $datetime, 440); func_mysqli_fetch_all_oo($link, $engine, "DATETIME NOT NULL", $datetime, $datetime, 450); func_mysqli_fetch_all_oo($link, $engine, "DATETIME", NULL, NULL, 460); diff --git a/ext/mysqli/tests/mysqli_fetch_assoc.phpt b/ext/mysqli/tests/mysqli_fetch_assoc.phpt index 6b4b753a74..00ca325f4f 100644 --- a/ext/mysqli/tests/mysqli_fetch_assoc.phpt +++ b/ext/mysqli/tests/mysqli_fetch_assoc.phpt @@ -34,7 +34,25 @@ require_once('skipifconnectfailure.inc'); mysqli_free_result($res); - if (!$res = mysqli_query($link, "SELECT 1 AS a, 2 AS a, 3 AS c, 4 AS C, NULL AS d, true AS e")) { + if (!$res = mysqli_query($link, "SELECT + 1 AS a, + 2 AS a, + 3 AS c, + 4 AS C, + NULL AS d, + true AS e, + 5 AS '-1', + 6 AS '-10', + 7 AS '-100', + 8 AS '-1000', + 9 AS '10000', + 'a' AS '100000', + 'b' AS '1000000', + 'c' AS '9', + 'd' AS '9', + 'e' AS '01', + 'f' AS '-02' + ")) { printf("[007] Cannot run query, [%d] %s\n", mysqli_errno($link), mysqli_error($link)); } print "[008]\n"; @@ -60,7 +78,7 @@ array(2) { [006] NULL [008] -array(5) { +array(15) { ["a"]=> string(1) "2" ["c"]=> @@ -71,6 +89,26 @@ array(5) { NULL ["e"]=> string(1) "1" + [-1]=> + string(1) "5" + [-10]=> + string(1) "6" + [-100]=> + string(1) "7" + [-1000]=> + string(1) "8" + [10000]=> + string(1) "9" + [100000]=> + string(1) "a" + [1000000]=> + string(1) "b" + [9]=> + string(1) "d" + ["01"]=> + string(1) "e" + ["-02"]=> + string(1) "f" } Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d @@ -86,7 +124,7 @@ array(2) { [006] NULL [008] -array(5) { +array(15) { [u"a"]=> unicode(1) "2" [u"c"]=> @@ -97,6 +135,26 @@ array(5) { NULL [u"e"]=> unicode(1) "1" + [-1]=> + unicode(1) "5" + [-10]=> + unicode(1) "6" + [-100]=> + unicode(1) "7" + [-1000]=> + unicode(1) "8" + [10000]=> + unicode(1) "9" + [100000]=> + unicode(1) "a" + [1000000]=> + unicode(1) "b" + [9]=> + unicode(1) "d" + [u"01"]=> + unicode(1) "e" + [u"-02"]=> + unicode(1) "f" } Warning: mysqli_fetch_assoc(): Couldn't fetch mysqli_result in %s on line %d diff --git a/ext/mysqli/tests/mysqli_fetch_object.phpt b/ext/mysqli/tests/mysqli_fetch_object.phpt index 0f8938a9d8..39cfd0518f 100644 --- a/ext/mysqli/tests/mysqli_fetch_object.phpt +++ b/ext/mysqli/tests/mysqli_fetch_object.phpt @@ -96,9 +96,12 @@ require_once('skipifconnectfailure.inc'); I'm using the procedural interface, this should not throw an exception. Also, I did not ask to get exceptions using the mysqli_options() */ - if ($TEST_EXPERIMENTAL) + try { if (false !== ($obj = mysqli_fetch_object($res, 'mysqli_fetch_object_construct', 'a'))) printf("[011] Should have failed\n"); + } catch (Exception $e) { + printf("%s\n", $e->getMessage()); + } mysqli_free_result($res); @@ -145,5 +148,6 @@ NULL Warning: mysqli_fetch_object(): Couldn't fetch mysqli_result in %s on line %d NULL +Parameter ctor_params must be an array Fatal error: Class 'this_class_does_not_exist' not found in %s on line %d \ No newline at end of file -- 2.50.1