]> granicus.if.org Git - php/commitdiff
Test changes for HEAD = synching with 5_3
authorUlf Wendel <uw@php.net>
Wed, 10 Oct 2007 10:56:33 +0000 (10:56 +0000)
committerUlf Wendel <uw@php.net>
Wed, 10 Oct 2007 10:56:33 +0000 (10:56 +0000)
ext/mysql/tests/mysql_fetch_assoc.phpt
ext/mysql/tests/mysql_fetch_field.phpt
ext/mysql/tests/mysql_fetch_object.phpt
ext/mysql/tests/mysql_list_fields.phpt
ext/mysql/tests/mysql_result.phpt

index 69bc3c652888c8dc67edc89d626f7e1ad3316eb9..172917b6fd146b18dafd74cde3d479b7d8cab44d 100644 (file)
@@ -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
index 50f9dff70542b0a3d7e75db28e531009ee60a7ad..7a50e23ca0c88d192d11382ba7a493b9c7aee951 100644 (file)
@@ -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!
index 8bb83429b961d852d5bb890916f5bccaa22291a5..cc20f738b0ec91d4078a5367062e2e7c3a172c05 100644 (file)
@@ -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)
index 5430d47c147a5d59749383938e1d20dc5a19190d..87b3cf6b898a6e36639afc2545e897e17d391dc7 100644 (file)
@@ -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!
index bc3e5bc009f71b0478fc319a2500c94056a74290..4217b2e3900f873a34bb69338bec9977f8e722ed 100644 (file)
@@ -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