added new tests

This commit is contained in:
Georg Richter 2003-02-12 10:40:19 +00:00
parent 2706394076
commit 91eeae5e1d
6 changed files with 187 additions and 0 deletions

43
ext/mysqli/tests/036.phpt Normal file
View File

@ -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)
}

34
ext/mysqli/tests/037.phpt Normal file
View File

@ -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)
}

31
ext/mysqli/tests/038.phpt Normal file
View File

@ -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)

24
ext/mysqli/tests/039.phpt Normal file
View File

@ -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)

31
ext/mysqli/tests/040.phpt Normal file
View File

@ -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)

24
ext/mysqli/tests/041.phpt Normal file
View File

@ -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)