]> granicus.if.org Git - php/commitdiff
added new tests
authorGeorg Richter <georg@php.net>
Wed, 12 Feb 2003 10:40:19 +0000 (10:40 +0000)
committerGeorg Richter <georg@php.net>
Wed, 12 Feb 2003 10:40:19 +0000 (10:40 +0000)
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]

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)