diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:37 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:34:37 -0400 |
commit | 10f5b47dc7c1cf2b9a00991629f43652710322d3 (patch) | |
tree | 3b727a16f652b8042d573e90f003868ffb3b56c7 /ext/mysqli/tests | |
parent | 0e920280a2e04b110827bb766b9f29e3d581c4ee (diff) | |
download | php-upstream/5.0.5.tar.gz |
Imported Upstream version 5.0.5upstream/5.0.5
Diffstat (limited to 'ext/mysqli/tests')
-rw-r--r-- | ext/mysqli/tests/033.phpt | 6 | ||||
-rw-r--r-- | ext/mysqli/tests/064.phpt | 21 | ||||
-rw-r--r-- | ext/mysqli/tests/065.phpt | 37 | ||||
-rw-r--r-- | ext/mysqli/tests/bug31668.phpt | 56 | ||||
-rw-r--r-- | ext/mysqli/tests/bug32405.phpt | 38 | ||||
-rw-r--r-- | ext/mysqli/tests/bug33090.phpt | 21 | ||||
-rw-r--r-- | ext/mysqli/tests/bug33263.phpt | 31 |
7 files changed, 207 insertions, 3 deletions
diff --git a/ext/mysqli/tests/033.phpt b/ext/mysqli/tests/033.phpt index 3a56b5c67..025539ea4 100644 --- a/ext/mysqli/tests/033.phpt +++ b/ext/mysqli/tests/033.phpt @@ -11,9 +11,9 @@ function test: mysqli_get_host_info $hinfo = mysqli_get_host_info($link); - var_dump($hinfo); + var_dump(str_replace('/','', $hinfo)); mysqli_close($link); ?> ---EXPECT-- -string(25) "Localhost via UNIX socket" +--EXPECTF-- +string(%d) "%s via %s"
\ No newline at end of file diff --git a/ext/mysqli/tests/064.phpt b/ext/mysqli/tests/064.phpt new file mode 100644 index 000000000..1d6358e53 --- /dev/null +++ b/ext/mysqli/tests/064.phpt @@ -0,0 +1,21 @@ +--TEST-- +NULL binding +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + include "connect.inc"; + + $mysql = new mysqli($host, $user, $passwd); + + $stmt = $mysql->prepare("SELECT NULL FROM DUAL"); + $stmt->execute(); + $stmt->bind_result($foo); + $stmt->fetch(); + $stmt->close(); + $mysql->close(); + + var_dump($foo); +?> +--EXPECT-- +NULL diff --git a/ext/mysqli/tests/065.phpt b/ext/mysqli/tests/065.phpt new file mode 100644 index 000000000..950a10a43 --- /dev/null +++ b/ext/mysqli/tests/065.phpt @@ -0,0 +1,37 @@ +--TEST-- +set character set +--SKIPIF-- +<?php +require_once('skipif.inc'); +?> +--FILE-- +<?php + include "connect.inc"; + + $mysql = new mysqli($host, $user, $passwd); + + $esc_str = chr(0xbf) . chr(0x5c); + + if ($mysql->set_charset("latin1")) { + /* 5C should be escaped */ + $len[0] = strlen($mysql->real_escape_string($esc_str)); + $charset[0] = $mysql->client_encoding(); + } + + if ($mysql->set_charset("gbk")) { + /* nothing should be escaped, it's a valid gbk character */ + $len[1] = strlen($mysql->real_escape_string($esc_str)); + $charset[1] = $mysql->client_encoding(); + } + + $mysql->close(); + var_dump($len[0]); + var_dump($len[1]); + var_dump($charset[0]); + var_dump($charset[1]); +?> +--EXPECT-- +int(3) +int(2) +string(6) "latin1" +string(3) "gbk" diff --git a/ext/mysqli/tests/bug31668.phpt b/ext/mysqli/tests/bug31668.phpt new file mode 100644 index 000000000..b813096a2 --- /dev/null +++ b/ext/mysqli/tests/bug31668.phpt @@ -0,0 +1,56 @@ +--TEST-- +Bug #31668 multi_query works exactly every other time (multi_query was global, now per connection) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + include "connect.inc"; + + $mysql = new mysqli($host, $user, $passwd, "test"); + $mysql->multi_query('SELECT 1;SELECT 2'); + do { + $res = $mysql->store_result(); + if ($mysql->errno == 0) { + while ($arr = $res->fetch_assoc()) { + var_dump($arr); + } + $res->free(); + } + } while ($mysql->next_result()); + var_dump($mysql->error, __LINE__); + $mysql->close(); + + $mysql = new mysqli($host, $user, $passwd, "test"); + $mysql->multi_query('SELECT 1;SELECT 2'); + do { + $res = $mysql->store_result(); + if ($mysql->errno == 0) { + while ($arr = $res->fetch_assoc()) { + var_dump($arr); + } + $res->free(); + } + } while ($mysql->next_result()); + var_dump($mysql->error, __LINE__); +?> +--EXPECTF-- +array(1) { + [1]=> + string(1) "1" +} +array(1) { + [2]=> + string(1) "2" +} +string(0) "" +int(%d) +array(1) { + [1]=> + string(1) "1" +} +array(1) { + [2]=> + string(1) "2" +} +string(0) "" +int(%d) diff --git a/ext/mysqli/tests/bug32405.phpt b/ext/mysqli/tests/bug32405.phpt new file mode 100644 index 000000000..9b58e3611 --- /dev/null +++ b/ext/mysqli/tests/bug32405.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #32405 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + include ("connect.inc"); + + /*** test mysqli_connect 127.0.0.1 ***/ + $link = mysqli_connect($host, $user, $passwd); + mysqli_select_db($link, "test"); + + /* two fields are needed. the problem does not occur with 1 field only selected. */ + $link->query("CREATE TABLE test_users(user_id int(10) unsigned NOT NULL auto_increment, login varchar(50) default '', PRIMARY KEY (user_id))"); + $link->query('INSERT INTO test_users VALUES (NULL, "user1"), (NULL, "user2"), (NULL, "user3"), (NULL, "user4")'); + + + if ($stmt = $link->prepare("SELECT SQL_NO_CACHE user_id, login FROM test_users")) { + $stmt->execute(); + $stmt->bind_result($col1, $col2); + while ($stmt->fetch()) { + var_dump($col1, $col2); + } + $stmt->close(); + } + + mysqli_query($link,"DROP TABLE test_users"); + mysqli_close($link); +?> +--EXPECT-- +int(1) +string(5) "user1" +int(2) +string(5) "user2" +int(3) +string(5) "user3" +int(4) +string(5) "user4" diff --git a/ext/mysqli/tests/bug33090.phpt b/ext/mysqli/tests/bug33090.phpt new file mode 100644 index 000000000..5c1cba961 --- /dev/null +++ b/ext/mysqli/tests/bug33090.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #33090 +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + include ("connect.inc"); + + /*** test mysqli_connect 127.0.0.1 ***/ + $link = mysqli_connect($host, $user, $passwd); + mysqli_select_db($link, "test"); + + if (!($link->prepare("this makes no sense"))) { + printf("%d\n", $link->errno); + printf("%s\n", $link->sqlstate); + } + $link->close(); +?> +--EXPECT-- +1064 +42000 diff --git a/ext/mysqli/tests/bug33263.phpt b/ext/mysqli/tests/bug33263.phpt new file mode 100644 index 000000000..44f9167c9 --- /dev/null +++ b/ext/mysqli/tests/bug33263.phpt @@ -0,0 +1,31 @@ +--TEST-- +bug #33263 (mysqli_real_connect in __construct) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + + include "connect.inc"; + + class test extends mysqli + { + public function __construct($host, $user, $passwd, $db) { + parent::init(); + parent::real_connect($host, $user, $passwd, $db); + } + } + + $mysql = new test($host, $user, $passwd, "test"); + + $stmt = $mysql->prepare("SELECT DATABASE()"); + $stmt->execute(); + $stmt->bind_result($db); + $stmt->fetch(); + $stmt->close(); + + var_dump($db); + + $mysql->close(); +?> +--EXPECT-- +string(4) "test" |