]> granicus.if.org Git - php/commitdiff
I forgot to mention: some will fail. In particular in unicode mode.
authorUlf Wendel <uw@php.net>
Thu, 12 Jul 2007 20:49:29 +0000 (20:49 +0000)
committerUlf Wendel <uw@php.net>
Thu, 12 Jul 2007 20:49:29 +0000 (20:49 +0000)
Next 10 in row to be tweaked:

     - take connection parameter from connect.inc
     - use proper UEXPECTF
     - have 'print "done!"' or similar at the end to detect crashes
     - whitespace changes where needed
     - take care of portability: PHP 5 vs. PHP 5, MySQL 4.1 - 6.0
     - understand return value checking as sometime that makes you type
       more when you write but makes you happy when you debug

ext/mysqli/tests/020.phpt
ext/mysqli/tests/021.phpt
ext/mysqli/tests/022.phpt
ext/mysqli/tests/023.phpt
ext/mysqli/tests/024.phpt
ext/mysqli/tests/025.phpt
ext/mysqli/tests/026.phpt
ext/mysqli/tests/027.phpt
ext/mysqli/tests/028.phpt
ext/mysqli/tests/029.phpt

index 17dc981b50e195088f525335a5d35aa707815b61..65ac2a0e1643b5d777a98a53d5e3d63f0bca4162 100644 (file)
@@ -4,27 +4,30 @@ mysqli bind_param/bind_result date
 <?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
+       /* NOTE: There's an option in mysqlnd which controls if data and
+       time are returned as unicode or not. Consider this if you consider
+       adding a UEXPECTF to the test. */
 
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
-               
+
        mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result");
-       mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time, 
-                                                        c3 timestamp(14), 
-                                                        c4 year, 
-                                                        c5 datetime, 
-                                                        c6 timestamp(4), 
+       mysqli_query($link,"CREATE TABLE test_bind_result(c1 date, c2 time,
+                                                        c3 timestamp(14),
+                                                        c4 year,
+                                                        c5 datetime,
+                                                        c6 timestamp(4),
                                                         c7 timestamp(6))");
 
        $stmt = mysqli_prepare($link, "INSERT INTO test_bind_result VALUES (?,?,?,?,?,?,?)");
        mysqli_bind_param($stmt, "sssssss", $d1, $d2, $d3, $d4, $d5, $d6, $d7);
 
-       $d1 = "2002-01-02";
+       $d1 = "2002-01-02";
        $d2 = "12:49:00";
        $d3 = "2002-01-02 17:46:59";
        $d4 = "2010";
@@ -37,9 +40,9 @@ mysqli bind_param/bind_result date
 
        $stmt = mysqli_prepare($link, "SELECT * FROM test_bind_result");
 
-       mysqli_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7);
-       
-       mysqli_execute($stmt);
+       mysqli_bind_result($stmt,$c1, $c2, $c3, $c4, $c5, $c6, $c7);
+
+       mysqli_execute($stmt);
        mysqli_fetch($stmt);
 
        $test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
@@ -48,6 +51,8 @@ mysqli bind_param/bind_result date
 
        mysqli_stmt_close($stmt);
        mysqli_close($link);
+
+       print "done!";
 ?>
 --EXPECTF--
 array(7) {
@@ -66,3 +71,4 @@ array(7) {
   [6]=>
   %s(19) "1999-12-29 00:00:00"
 }
+done!
\ No newline at end of file
index e351bd45408f4563775ac2ccb9145d2d939e2874..b9f367afda92044d417c763fdac7f4cc04e5b6f1 100644 (file)
@@ -1,18 +1,18 @@
 --TEST--
-mysqli bind_param+bind_result char/text 
+mysqli bind_param+bind_result char/text
 --SKIPIF--
 <?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
 
-       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
-       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
+       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
+       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
 
        $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
        mysqli_bind_param($stmt, "ss", $q1, $q2);
@@ -32,11 +32,21 @@ mysqli bind_param+bind_result char/text
 
        mysqli_stmt_close($stmt);
        mysqli_close($link);
+       print "done!";
 ?>
 --EXPECTF--
 array(2) {
   [0]=>
-  %s(10) "1234567890"
+  string(10) "1234567890"
+  [1]=>
+  %s(14) "this is a test"
+}
+done!
+--UEXPECTF--
+array(2) {
+  [0]=>
+  unicode(10) "1234567890"
   [1]=>
   %s(14) "this is a test"
 }
+done!
\ No newline at end of file
index a716d848fd50f7908055ecb13a2b1d7e4688edf1..969936ed8ab4b0f516eb5d0c16f3cf044a95f700 100644 (file)
@@ -1,18 +1,18 @@
 --TEST--
-mysqli bind_param/bind_result char/text long 
+mysqli bind_param/bind_result char/text long
 --SKIPIF--
 <?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
 
-       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
-       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
+       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
+       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text)");
 
 
        $stmt = mysqli_prepare($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
@@ -36,11 +36,22 @@ mysqli bind_param/bind_result char/text long
 
        mysqli_stmt_close($stmt);
        mysqli_close($link);
+
+       print "done!";
 ?>
 --EXPECTF--
 array(2) {
   [0]=>
-  %s(10) "1234567890"
+  string(10) "1234567890"
+  [1]=>
+  %s(13) "32K String ok"
+}
+done!
+--UEXPECTF--
+array(2) {
+  [0]=>
+  unicode(10) "1234567890"
   [1]=>
   %s(13) "32K String ok"
 }
+done!
\ No newline at end of file
index 24a717a6eb4d5666bd6d3dde6105c1f88a3669f0..97398001f890e9877cbea27fb566987a0563e1bf 100644 (file)
@@ -5,15 +5,15 @@ mysqli bind_param/bind_prepare fetch long values
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
 
-       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
-       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
+       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
+       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 int unsigned,
                                                      c2 int unsigned,
                                                      c3 int,
                                                      c4 int,
@@ -45,6 +45,8 @@ mysqli bind_param/bind_prepare fetch long values
 
        mysqli_stmt_close($stmt);
        mysqli_close($link);
+
+       print "done!";
 ?>
 --EXPECT--
 array(7) {
@@ -63,3 +65,4 @@ array(7) {
   [6]=>
   int(0)
 }
+done!
\ No newline at end of file
index f0d0a6407acccad04361017cca838498f15273b1..58302b39d4fadc43daa02e21e1aacd3c1066b4b7 100644 (file)
@@ -5,15 +5,15 @@ mysqli bind_param/bind_result short values
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
 
-       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
-       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
+       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
+       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 smallint unsigned,
                                                      c2 smallint unsigned,
                                                      c3 smallint,
                                                      c4 smallint,
@@ -46,6 +46,7 @@ mysqli bind_param/bind_result short values
 
        mysqli_stmt_close($stmt);
        mysqli_close($link);
+       print "done!";
 ?>
 --EXPECT--
 array(7) {
@@ -64,3 +65,4 @@ array(7) {
   [6]=>
   int(0)
 }
+done!
\ No newline at end of file
index f3338cf4671197164b38503cf732a218ff420939..8d3e2388e1da46397f664eebf3c56c9c2e1f7da9 100644 (file)
@@ -5,15 +5,15 @@ mysqli bind_param/bind_result tinyint values
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
 
-       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
-       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
+       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
+       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 tinyint,
                                                      c2 tinyint unsigned,
                                                      c3 tinyint not NULL,
                                                      c4 tinyint,
@@ -50,6 +50,8 @@ mysqli bind_param/bind_result tinyint values
 
        mysqli_stmt_close($stmt);
        mysqli_close($link);
+
+       print "done!";
 ?>
 --EXPECT--
 array(7) {
@@ -68,3 +70,4 @@ array(7) {
   [6]=>
   int(0)
 }
+done!
\ No newline at end of file
index ad4fe67b8481957ed8216d9b53357b0676bbb404..04faf108c6664e96226a2fa11c0de2ddc934e37e 100644 (file)
@@ -1,19 +1,19 @@
 --TEST--
-mysqli bind_param/bind_result with send_long_data 
+mysqli bind_param/bind_result with send_long_data
 --SKIPIF--
 <?php require_once('skipif.inc'); ?>
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
        mysqli_query($link, "SET sql_mode=''");
 
-       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
-       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
+       mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch");
+       mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 varchar(10), c2 text)");
 
        $stmt = mysqli_prepare ($link, "INSERT INTO test_bind_fetch VALUES (?,?)");
        mysqli_bind_param($stmt, "sb", $c1, $c2);
@@ -39,11 +39,20 @@ mysqli bind_param/bind_result with send_long_data
        mysqli_stmt_close($stmt);
 
        mysqli_close($link);
-?>
+       print "done!";
 --EXPECTF--
 array(2) {
   [0]=>
-  %s(10) "Hello Worl"
+  string(10) "Hello Worl"
+  [1]=>
+  string(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence."
+}
+done!
+--UEXPECTF--
+array(2) {
+  [0]=>
+  unicode(10) "Hello Worl"
   [1]=>
   %s(99) "This is the first sentence. And this is the second sentence. And finally this is the last sentence."
 }
+done!
\ No newline at end of file
index 9f8eadf9ddc345ac31b23c4f6aab0f674ef3cd9a..dc0f1af928de53400a63e09628b83e8208875b4d 100644 (file)
@@ -5,9 +5,9 @@ function test: mysqli_stat
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $status = mysqli_stat($link);
 
@@ -15,6 +15,8 @@ function test: mysqli_stat
        var_dump(strlen($status) > 0);
 
        mysqli_close($link);
+       print "done!";
 ?>
 --EXPECT--
 bool(true)
+done!
\ No newline at end of file
index b11da2ae4496a648e5c1adc7d296635e8d1dd17d..44704dcae01481a82b5b0a3919c006578bbfdfa1 100644 (file)
@@ -5,15 +5,20 @@ function test: mysqli_character_set_name
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
        $cset = substr(mysqli_character_set_name($link),0,6);
 
        var_dump($cset);
 
        mysqli_close($link);
+       print "done!";
 ?>
 --EXPECTF--
-%s(%d) "%s"
+string(%d) "%s"
+done!
+--UEXPECTF--
+unicode(%d) "%s"
+done!
\ No newline at end of file
index 318e6aeb9ecd99326d3540268c2d0a2101b154ff..4970736f2a6c50e9f7c44049430b52e684164151 100644 (file)
@@ -5,11 +5,11 @@ function test: mysqli_affected_rows
 --FILE--
 <?php
        include "connect.inc";
-       
+
        /*** test mysqli_connect 127.0.0.1 ***/
-       $link = mysqli_connect($host, $user, $passwd);
+       $link = mysqli_connect($host, $user, $passwd, $db, $port, $socket);
 
-       mysqli_select_db($link, "test");
+       mysqli_select_db($link, $db);
 
        mysqli_query($link, "drop table if exists general_test");
        mysqli_query($link, "create table general_test (a int)");
@@ -20,6 +20,8 @@ function test: mysqli_affected_rows
        var_dump($afc);
 
        mysqli_close($link);
+       print "done!";
 ?>
 --EXPECT--
 int(3)
+done!
\ No newline at end of file