]> granicus.if.org Git - php/commitdiff
This commit was manufactured by cvs2svn to create branch 'PHP_4_3'.
authorSVN Migration <svn@php.net>
Thu, 13 Feb 2003 17:25:32 +0000 (17:25 +0000)
committerSVN Migration <svn@php.net>
Thu, 13 Feb 2003 17:25:32 +0000 (17:25 +0000)
ext/mysqli/tests/001.phpt [new file with mode: 0644]
ext/mysqli/tests/036.phpt [new file with mode: 0644]
ext/mysqli/tests/037.phpt [new file with mode: 0644]
ext/mysqli/tests/038.phpt [new file with mode: 0644]
ext/mysqli/tests/039.phpt [new file with mode: 0644]
ext/mysqli/tests/040.phpt [new file with mode: 0644]
ext/mysqli/tests/041.phpt [new file with mode: 0644]
ext/mysqli/tests/043.phpt [new file with mode: 0644]
ext/mysqli/tests/044.phpt [new file with mode: 0644]
ext/standard/tests/strings/bug22207.phpt [new file with mode: 0644]

diff --git a/ext/mysqli/tests/001.phpt b/ext/mysqli/tests/001.phpt
new file mode 100644 (file)
index 0000000..fca937c
--- /dev/null
@@ -0,0 +1,54 @@
+--TEST--
+mysqli connect
+--FILE--
+<?
+       $user = "root";
+       $passwd = "";
+       $dbname = "test";
+       $test = "";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("127.0.0.1", $user, $passwd);
+       $test .= ($link) ? "1" : "0";
+       mysqli_close($link);
+
+       /*** test mysqli_connect localhost ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+       $test .= ($link) ? "1" : "0";
+       mysqli_close($link);
+
+       /*** test mysqli_connect localhost:port ***/
+       $link = mysqli_connect("localhost", $user, $passwd, "", 3306);
+       $test .= ($link) ? "1" : "0";
+       mysqli_close($link);
+
+       /*** test mysqli_real_connect ***/
+       $link = mysqli_init();  
+       $test.= (mysqli_real_connect($link, "localhost", $user, $passwd)) 
+               ? "1" : "0";
+       mysqli_close($link);
+
+       /*** test mysqli_real_connect with db ***/
+       $link = mysqli_init();  
+       $test .= (mysqli_real_connect($link, "localhost", $user, $passwd, $dbname)) 
+               ? "1" : "0";
+       mysqli_close($link);
+
+       /*** test mysqli_real_connect with port ***/
+       $link = mysqli_init();  
+       $test .= (mysqli_real_connect($link, "localhost", $user, $passwd, $dbname, 3306))
+               ? "1":"0";
+       mysqli_close($link);
+
+       /*** test mysqli_real_connect compressed ***/
+       $link = mysqli_init();  
+       $test .= (mysqli_real_connect($link, "localhost", $user, $passwd, $dbname, 0, NULL, MYSQLI_CLIENT_COMPRESS)) 
+               ? "1" : "0";
+       mysqli_close($link);
+
+       /* todo ssl connections */
+
+       var_dump($test);
+?>
+--EXPECT--
+string(7) "1111111"
diff --git a/ext/mysqli/tests/036.phpt b/ext/mysqli/tests/036.phpt
new file mode 100644 (file)
index 0000000..080c6e3
--- /dev/null
@@ -0,0 +1,43 @@
+--TEST--
+function test: mysqli_insert_id()
+--FILE--
+<?php
+
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       mysqli_select_db($link, "test");
+
+       mysqli_query($link, "DROP TABLE IF EXISTS t036");
+
+       mysqli_query($link, "CREATE TABLE t036 (a bigint not null auto_increment primary key, b varchar(10))");
+
+
+       mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo1')");
+       $test[] = mysqli_insert_id($link);
+
+       /* we have to insert more values, cause lexer sets auto_increment to max_int
+          see mysql bug #54. So we don't check for the value, only for type (which must
+          be type string) 
+       */      
+          
+       mysqli_query($link, "ALTER TABLE t036 AUTO_INCREMENT=9999999999999998");
+       mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo2')");
+       mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo3')");
+       mysqli_query($link, "INSERT INTO t036 (b) VALUES ('foo4')");
+       $x = mysqli_insert_id($link);
+       $test[] = is_string($x);
+       
+       var_dump($test);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  int(1)
+  [1]=>
+  bool(true)
+}
diff --git a/ext/mysqli/tests/037.phpt b/ext/mysqli/tests/037.phpt
new file mode 100644 (file)
index 0000000..f8b8a13
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+function test: mysqli_field_count()
+--FILE--
+<?php
+
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       mysqli_select_db($link, "test");
+
+       mysqli_query($link, "DROP TABLE IF EXISTS test_result");
+
+       mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
+
+       mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
+       $ir[] = mysqli_field_count($link);
+
+       mysqli_real_query($link, "SELECT * FROM test_result");
+       $ir[] = mysqli_field_count($link);
+       
+       
+       var_dump($ir);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+array(2) {
+  [0]=>
+  int(0)
+  [1]=>
+  int(2)
+}
diff --git a/ext/mysqli/tests/038.phpt b/ext/mysqli/tests/038.phpt
new file mode 100644 (file)
index 0000000..858b3e3
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+function test: mysqli_num_fields()
+--FILE--
+<?php
+
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       mysqli_select_db($link, "test");
+
+       mysqli_query($link, "DROP TABLE IF EXISTS test_result");
+
+       mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
+
+       mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
+
+       mysqli_real_query($link, "SELECT * FROM test_result");
+       if (mysqli_field_count($link)) {
+               $result = mysqli_store_result($link);
+               $num = mysqli_num_fields($result);
+               mysqli_free_result($result);
+       }
+
+       var_dump($num);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+int(2)
diff --git a/ext/mysqli/tests/039.phpt b/ext/mysqli/tests/039.phpt
new file mode 100644 (file)
index 0000000..6ddb37b
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+function test: mysqli_num_fields() 2
+--FILE--
+<?php
+
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       mysqli_real_query($link, "SHOW VARIABLES");
+
+       if (mysqli_field_count($link)) {
+               $result = mysqli_store_result($link);
+               $num = mysqli_num_fields($result);
+               mysqli_free_result($result);
+       }
+
+       var_dump($num);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+int(2)
diff --git a/ext/mysqli/tests/040.phpt b/ext/mysqli/tests/040.phpt
new file mode 100644 (file)
index 0000000..477e2a5
--- /dev/null
@@ -0,0 +1,31 @@
+--TEST--
+function test: mysqli_num_rows()
+--FILE--
+<?php
+
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       mysqli_select_db($link, "test");
+
+       mysqli_query($link, "DROP TABLE IF EXISTS test_result");
+
+       mysqli_query($link, "CREATE TABLE test_result (a int, b varchar(10))");
+
+       mysqli_query($link, "INSERT INTO test_result VALUES (1, 'foo')");
+
+       mysqli_real_query($link, "SELECT * FROM test_result");
+       if (mysqli_field_count($link)) {
+               $result = mysqli_store_result($link);
+               $num = mysqli_num_rows($result);
+               mysqli_free_result($result);
+       }
+
+       var_dump($num);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+int(1)
diff --git a/ext/mysqli/tests/041.phpt b/ext/mysqli/tests/041.phpt
new file mode 100644 (file)
index 0000000..6fb8ee7
--- /dev/null
@@ -0,0 +1,24 @@
+--TEST--
+function test: mysqli_warning_count()
+--FILE--
+<?php
+
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       mysqli_select_db($link, "test");
+
+       mysqli_query($link, "DROP TABLE IF EXISTS test_warnings");
+
+       mysqli_query($link, "CREATE TABLE test_warnings (a int not null");
+
+       mysqli_query($link, "INSERT INTO test_warnings VALUES (1),(2),(NULL)");
+       $num = mysqli_warning_count($link);
+       var_dump($num);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+int(1)
diff --git a/ext/mysqli/tests/043.phpt b/ext/mysqli/tests/043.phpt
new file mode 100644 (file)
index 0000000..9c02c32
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+mysqli_bind_param (UPDATE)
+--FILE--
+<?php
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       mysqli_select_db($link, "test");
+
+       mysqli_query($link,"DROP TABLE IF EXISTS test_update");
+       mysqli_query($link,"CREATE TABLE test_update(a varchar(10),
+                                                     b int)");
+
+       mysqli_query($link, "INSERT INTO test_update VALUES ('foo', 2)");
+
+       $stmt = mysqli_prepare($link, "UPDATE test_update SET a=?,b=? WHERE b=?");
+       mysqli_bind_param($stmt, &$c1,MYSQLI_BIND_STRING,&$c2,MYSQLI_BIND_INT, &$c3, MYSQLI_BIND_INT);
+
+       $c1 = "Rasmus";
+       $c2 = 1;
+       $c3 = 2;
+
+       mysqli_execute($stmt);
+       mysqli_stmt_close($stmt);
+
+       $result = mysqli_query($link, "SELECT concat(a, ' is No. ', b) FROM test_update");
+       $test = mysqli_fetch_row($result);
+       mysqli_free_result($result);
+
+       var_dump($test);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  string(15) "Rasmus is No. 1"
+}
diff --git a/ext/mysqli/tests/044.phpt b/ext/mysqli/tests/044.phpt
new file mode 100644 (file)
index 0000000..5f72f65
--- /dev/null
@@ -0,0 +1,19 @@
+--TEST--
+mysqli_get_server_version
+--FILE--
+<?php
+       include "connect.inc";
+       
+       /*** test mysqli_connect 127.0.0.1 ***/
+       $link = mysqli_connect("localhost", $user, $passwd);
+
+       $i = mysqli_get_server_version($link);
+
+       $test = $i / $i;
+
+       var_dump($test);
+
+       mysqli_close($link);
+?>
+--EXPECT--
+int(1)
diff --git a/ext/standard/tests/strings/bug22207.phpt b/ext/standard/tests/strings/bug22207.phpt
new file mode 100644 (file)
index 0000000..1623fb8
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #22207 (missing 0 when using the e notation in *printf functions)
+--FILE--
+<?php
+       printf("%10.5e\n", 1.1); 
+       var_dump(sprintf("%10.5e\n", 1.1));
+?>
+--EXPECT--
+1.1000e+0
+string(17) "       1.1000e+0
+"