diff options
author | Ulf Wendel <uw@php.net> | 2007-10-10 10:56:33 +0000 |
---|---|---|
committer | Ulf Wendel <uw@php.net> | 2007-10-10 10:56:33 +0000 |
commit | 23f2c54784a6154fc949897fb24842c21c6f4d43 (patch) | |
tree | e229c42ae501ab8f5c48a21a947679cdff41a6ad | |
parent | b67be59f4e8a2b3232582a04f513a6f15856a8f9 (diff) | |
download | php-git-23f2c54784a6154fc949897fb24842c21c6f4d43.tar.gz |
Test changes for HEAD = synching with 5_3
-rw-r--r-- | ext/mysql/tests/mysql_fetch_assoc.phpt | 40 | ||||
-rw-r--r-- | ext/mysql/tests/mysql_fetch_field.phpt | 143 | ||||
-rw-r--r-- | ext/mysql/tests/mysql_fetch_object.phpt | 19 | ||||
-rw-r--r-- | ext/mysql/tests/mysql_list_fields.phpt | 8 | ||||
-rw-r--r-- | ext/mysql/tests/mysql_result.phpt | 26 |
5 files changed, 220 insertions, 16 deletions
diff --git a/ext/mysql/tests/mysql_fetch_assoc.phpt b/ext/mysql/tests/mysql_fetch_assoc.phpt index 69bc3c6528..172917b6fd 100644 --- a/ext/mysql/tests/mysql_fetch_assoc.phpt +++ b/ext/mysql/tests/mysql_fetch_assoc.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_fetch_assoc() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -46,6 +46,16 @@ if (false !== ($tmp = mysql_fetch_assoc($res))) mysql_close($link); +include('table.inc'); +if (!$res = mysql_query("SELECT id, label, id AS _id, CONCAT(label, 'a') _label, NULL as _foo FROM test _test ORDER BY id ASC LIMIT 1", $link)) { + printf("[009] [%d] %s\n", mysql_errno($link), $mysql_error($link)); +} +print "[010]\n"; +var_dump(mysql_fetch_assoc($res)); +mysql_free_result($res); + +mysql_close($link); + print "done!"; ?> --EXPECTF-- @@ -73,6 +83,19 @@ array(5) { } Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d +[010] +array(5) { + ["id"]=> + string(1) "1" + ["label"]=> + string(1) "a" + ["_id"]=> + string(1) "1" + ["_label"]=> + string(2) "aa" + ["_foo"]=> + NULL +} done! --UEXPECTF-- [005] @@ -99,4 +122,17 @@ array(5) { } Warning: mysql_fetch_assoc(): %d is not a valid MySQL result resource in %s on line %d +[010] +array(5) { + [u"id"]=> + unicode(1) "1" + [u"label"]=> + unicode(1) "a" + [u"_id"]=> + unicode(1) "1" + [u"_label"]=> + unicode(2) "aa" + [u"_foo"]=> + NULL +} done!
\ No newline at end of file diff --git a/ext/mysql/tests/mysql_fetch_field.phpt b/ext/mysql/tests/mysql_fetch_field.phpt index 50f9dff705..7a50e23ca0 100644 --- a/ext/mysql/tests/mysql_fetch_field.phpt +++ b/ext/mysql/tests/mysql_fetch_field.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_fetch_field() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -21,7 +21,6 @@ require_once('skipifconnectfailure.inc'); require('table.inc'); - $version = mysql_get_server_info($link); if (!preg_match('@(\d+)\.(\d+)\.(\d+)@ism', $version, $matches)) printf("[003] Cannot get server version\n"); @@ -105,6 +104,32 @@ require_once('skipifconnectfailure.inc'); mysql_free_result($res); } + if (!mysql_query("DROP TABLE IF EXISTS test", $link)) + printf("[013] [%d] %s\n", mysql_errno($link), mysql_error($link)); + + if (!mysql_query("CREATE TABLE test(id INT DEFAULT 1)")) + printf("[014] [%d] %s\n", mysql_errno($link), mysql_error($link)); + + if (!mysql_query("INSERT INTO test(id) VALUES (2)")) + printf("[015] [%d] %s\n", mysql_errno($link), mysql_error($link)); + + if (!$res = mysql_query("SELECT id FROM test", $link)) { + printf("[016] [%d] %s\n", mysql_errno($link), mysql_error($link)); + } + + var_dump(mysql_fetch_field($res)); + mysql_free_result($res); + + if (!$res = mysql_query("SELECT id FROM test", $link)) { + printf("[017] [%d] %s\n", mysql_errno($link), mysql_error($link)); + } + $res = mysql_list_fields($db, 'test'); + while ($tmp = mysql_fetch_field($res)) + if ($tmp->name == 'id') + var_dump($tmp); + + mysql_free_result($res); + mysql_close($link); print "done!"; ?> @@ -170,6 +195,62 @@ bool(false) Warning: mysql_fetch_field(): Bad field offset in %s on line %d Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d +object(stdClass)#%d (13) { + ["name"]=> + string(2) "id" + ["table"]=> + string(4) "test" + ["def"]=> + string(0) "" + ["max_length"]=> + int(1) + ["not_null"]=> + int(0) + ["primary_key"]=> + int(0) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(1) + ["blob"]=> + int(0) + ["type"]=> + string(3) "int" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} +object(stdClass)#%d (13) { + ["name"]=> + string(2) "id" + ["table"]=> + string(4) "test" + ["def"]=> + string(1) "1" + ["max_length"]=> + int(0) + ["not_null"]=> + int(0) + ["primary_key"]=> + int(0) + ["multiple_key"]=> + int(0) + ["unique_key"]=> + int(0) + ["numeric"]=> + int(1) + ["blob"]=> + int(0) + ["type"]=> + string(3) "int" + ["unsigned"]=> + int(0) + ["zerofill"]=> + int(0) +} done! --UEXPECTF-- object(stdClass)#%d (13) { @@ -233,4 +314,60 @@ bool(false) Warning: mysql_fetch_field(): Bad field offset in %s on line %d Warning: mysql_fetch_field(): %d is not a valid MySQL result resource in %s on line %d +object(stdClass)#%d (13) { + [u"name"]=> + unicode(2) "id" + [u"table"]=> + unicode(4) "test" + [u"def"]=> + unicode(0) "" + [u"max_length"]=> + int(1) + [u"not_null"]=> + int(0) + [u"primary_key"]=> + int(0) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(1) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(3) "int" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} +object(stdClass)#%d (13) { + [u"name"]=> + unicode(2) "id" + [u"table"]=> + unicode(4) "test" + [u"def"]=> + unicode(1) "1" + [u"max_length"]=> + int(0) + [u"not_null"]=> + int(0) + [u"primary_key"]=> + int(0) + [u"multiple_key"]=> + int(0) + [u"unique_key"]=> + int(0) + [u"numeric"]=> + int(1) + [u"blob"]=> + int(0) + [u"type"]=> + unicode(3) "int" + [u"unsigned"]=> + int(0) + [u"zerofill"]=> + int(0) +} done! diff --git a/ext/mysql/tests/mysql_fetch_object.phpt b/ext/mysql/tests/mysql_fetch_object.phpt index 8bb83429b9..cc20f738b0 100644 --- a/ext/mysql/tests/mysql_fetch_object.phpt +++ b/ext/mysql/tests/mysql_fetch_object.phpt @@ -1,8 +1,8 @@ --TEST-- mysql_fetch_object() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- @@ -50,7 +50,16 @@ var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', null)); var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a'))); var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b'))); var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b', 'c'))); +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', "no array and not null")); var_dump(mysql_fetch_object($res)); +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_construct', array('a', 'b'))); + +class mysql_fetch_object_private_construct { + private function __construct($a, $b) { + var_dump($a); + } +} +var_dump(mysql_fetch_object($res, 'mysql_fetch_object_private_construct', array('a', 'b'))); mysql_free_result($res); @@ -129,6 +138,9 @@ object(mysql_fetch_object_construct)#%d (4) { } bool(false) bool(false) +bool(false) +bool(false) +bool(false) Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d bool(false) @@ -195,6 +207,9 @@ object(mysql_fetch_object_construct)#%d (4) { } bool(false) bool(false) +bool(false) +bool(false) +bool(false) Warning: mysql_fetch_object(): %d is not a valid MySQL result resource in %s on line %d bool(false) diff --git a/ext/mysql/tests/mysql_list_fields.phpt b/ext/mysql/tests/mysql_list_fields.phpt index 5430d47c14..87b3cf6b89 100644 --- a/ext/mysql/tests/mysql_list_fields.phpt +++ b/ext/mysql/tests/mysql_list_fields.phpt @@ -12,10 +12,12 @@ include_once "connect.inc"; $tmp = NULL; $link = NULL; -if (false !== ($tmp = @mysql_list_fields($link, $link))) - printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); +// This will implicitly try to connect, and we don't want it +//if (false !== ($tmp = mysql_list_fields($link, $link))) +// printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp); require('table.inc'); + if (!$res = mysql_list_fields($db, 'test', $link)) printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); @@ -28,4 +30,4 @@ mysql_close($link); print "done!"; ?> --EXPECTF-- -done!
\ No newline at end of file +done! diff --git a/ext/mysql/tests/mysql_result.phpt b/ext/mysql/tests/mysql_result.phpt index bc3e5bc009..4217b2e390 100644 --- a/ext/mysql/tests/mysql_result.phpt +++ b/ext/mysql/tests/mysql_result.phpt @@ -1,13 +1,13 @@ --TEST-- mysql_result() --SKIPIF-- -<?php -require_once('skipif.inc'); +<?php +require_once('skipif.inc'); require_once('skipifconnectfailure.inc'); ?> --FILE-- <?php -include "connect.inc"; +require_once("connect.inc"); $tmp = NULL; $link = NULL; @@ -20,8 +20,8 @@ if (!is_null($tmp = @mysql_result())) if (!is_null($tmp = @mysql_result($link))) printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); -require('table.inc'); -if (!$res = mysql_query("SELECT id, label, id AS _id, CONCAT(label, 'a') _label, NULL as _foo FROM test _test ORDER BY id LIMIT 1", $link)) { +require_once('table.inc'); +if (!$res = mysql_query("SELECT id, label, id AS _id, CONCAT(label, 'a') _label, NULL as _foo FROM test _test ORDER BY id ASC LIMIT 1", $link)) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } @@ -50,6 +50,8 @@ print "_label\n"; var_dump(mysql_result($res, 0, '_label')); print "_foo\n"; var_dump(mysql_result($res, 0, '_foo')); +var_dump(mysql_result($res, 0, 'test.id')); +var_dump(mysql_result($res, 0, 'test.label')); mysql_free_result($res); @@ -97,6 +99,12 @@ string(2) "aa" _foo NULL +Warning: mysql_result(): test.id not found in MySQL result index %d in %s on line %d +bool(false) + +Warning: mysql_result(): test.label not found in MySQL result index %d in %s on line %d +bool(false) + Warning: mysql_result(): %d is not a valid MySQL result resource in %s on line %d bool(false) done! @@ -135,10 +143,16 @@ bool(false) _id unicode(1) "1" _label -unicode(2) "aa" +string(2) "aa" _foo NULL +Warning: mysql_result(): test.id not found in MySQL result index %d in %s on line %d +bool(false) + +Warning: mysql_result(): test.label not found in MySQL result index %d in %s on line %d +bool(false) + Warning: mysql_result(): %d is not a valid MySQL result resource in %s on line %d bool(false) done!
\ No newline at end of file |