uw Wed Oct 10 09:53:34 2007 UTC
Added files: (Branch: PHP_5_3)
/php-src/ext/mysql/tests mysql_data_seek.phpt mysql_db_name.phpt
mysql_db_query.phpt mysql_drop_db.phpt
mysql_get_client_info.phpt
mysql_get_host_info.phpt
mysql_get_proto_info.phpt
mysql_get_server_info.phpt mysql_info.phpt
mysql_insert_id.phpt
Log:
Next set of new tests - more to follow. Trying to find reasonable commit
size...
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_data_seek.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_data_seek.phpt
+++ php-src/ext/mysql/tests/mysql_data_seek.phpt
--TEST--
mysql_data_seek()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
include "connect.inc";
$tmp = NULL;
$link = NULL;
if (NULL !== ($tmp = @mysql_data_seek()))
printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
if (NULL !== ($tmp = @mysql_data_seek($link)))
printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
if (false !== ($tmp = @mysql_data_seek($link, $link)))
printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
require('table.inc');
if (!$res = mysql_query('SELECT * FROM test ORDER BY id LIMIT 4', $link))
printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (true !== ($tmp = mysql_data_seek($res, 3)))
printf("[005] Expecting boolean/true, got %s/%s\n", gettype($tmp),
$tmp);
$row = mysql_fetch_assoc($res);
if (4 != $row['id'])
printf("[006] Expecting record 4/d, got record %s/%s\n", $row['id'],
$row['label']);
if (true !== ($tmp = mysql_data_seek($res, 0)))
printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp),
$tmp);
$row = mysql_fetch_assoc($res);
if (1 != $row['id'])
printf("[008] Expecting record 1/a, got record %s/%s\n", $row['id'],
$row['label']);
if (false !== ($tmp = mysql_data_seek($res, 4)))
printf("[009] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
if (false !== ($tmp = mysql_data_seek($res, -1)))
printf("[010] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
mysql_free_result($res);
if (!$res = mysql_unbuffered_query('SELECT * FROM test ORDER BY id',
$link))
printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (false !== ($tmp = mysql_data_seek($res, 3)))
printf("[012] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
mysql_free_result($res);
if (false !== ($tmp = mysql_data_seek($res, 1)))
printf("[013] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
mysql_close($link);
print "done!\n";
?>
--EXPECTF--
Warning: mysql_data_seek(): Offset 4 is invalid for MySQL result index %d (or
the query data is unbuffered) in %s on line %d
Warning: mysql_data_seek(): Offset -1 is invalid for MySQL result index %d (or
the query data is unbuffered) in %s on line %d
Warning: mysql_data_seek(): Offset 3 is invalid for MySQL result index %d (or
the query data is unbuffered) in %s on line %d
Warning: mysql_data_seek(): %d is not a valid MySQL result resource in %s on
line %d
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_db_name.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_db_name.phpt
+++ php-src/ext/mysql/tests/mysql_db_name.phpt
--TEST--
mysql_db_name()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include "connect.inc";
$tmp = NULL;
$link = NULL;
if (NULL !== ($tmp = @mysql_db_name()))
printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
if (false !== ($tmp = @mysql_db_name($link, $link)))
printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
require('table.inc');
if (!$res = mysql_list_dbs($link))
printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!$num = mysql_num_rows($res))
printf("[004] Empty database list? [%d] %s\n", mysql_errno($link),
mysql_error($link));
if (false !== ($tmp = mysql_db_name($res, -1)))
printf("[005] Expecting boolean/false, got %s/%s. [%d] %s\n",
gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
if (false !== ($tmp = mysql_db_name($res, $num + 1)))
printf("[006] Expecting boolean/false, got %s/%s. [%d] %s\n",
gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
$unicode = (boolean)ini_get('unicode.semantics');
for ($i = 0; $i < $num; $i++) {
if ('' === ($dbname = mysql_db_name($res, $i)))
printf("[%03d] Got empty database name! [%d] %s\n",
(($i * 2) + 1) + 6, mysql_errno($link), mysql_error($link));
if ($unicode && !is_unicode($dbname)) {
printf("[%03d] Expecting unicode string! [%d] %s\n",
(($i * 2) + 2) + 6, mysql_errno($link), mysql_error($link));
var_inspect($dbname);
}
}
mysql_free_result($res);
if (false !== ($tmp = mysql_db_name($res, $num)))
printf("[999] Expecting boolean/false, got %s/%s. [%d] %s\n",
gettype($tmp), $tmp, mysql_errno($link), mysql_error($link));
mysql_close($link);
print "done!\n";
?>
--EXPECTF--
Warning: mysql_db_name(): Unable to jump to row -1 on MySQL result index %d in
%s on line %d
Warning: mysql_db_name(): Unable to jump to row %d on MySQL result index %d in
%s on line %d
Warning: mysql_db_name(): %d is not a valid MySQL result resource in %s on line
%d
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_db_query.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_db_query.phpt
+++ php-src/ext/mysql/tests/mysql_db_query.phpt
--TEST--
mysql_db_query()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include "connect.inc";
// NOTE: this function is deprecated. We do only the most necessary
// to test it. We don't test all aspects of the documented behaviour.
$tmp = NULL;
$link = NULL;
if (NULL !== ($tmp = @mysql_db_query()))
printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
if (NULL !== ($tmp = @mysql_db_query($link)))
printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
if (NULL !== ($tmp = @mysql_db_query($link)))
printf("[003] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
require('table.inc');
if (!$res = mysql_db_query($db, 'SELECT id, label FROM test ORDER BY id
LIMIT 1', $link))
printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
$row = mysql_fetch_assoc($res);
if (1 != $row['id'])
printf("[005] Expecting record 1/a, got record %s/%s\n", $row['id'],
$row['label']);
if (ini_get('unicode.semantics') && !is_unicode($row['label'])) {
printf("[006] No unicode returned! [%d] %s\n", mysql_errno($link),
mysql_error($link));
var_inspect($row);
}
mysql_free_result($res);
mysql_close($link);
print "done!\n";
?>
--EXPECTF--
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_drop_db.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_drop_db.phpt
+++ php-src/ext/mysql/tests/mysql_drop_db.phpt
--TEST--
mysql_drop_db()
--SKIPIF--
<?php
require_once('skipif.inc');
if (!function_exists('mysql_drop_db'))
die("Skip function is deprecated and not available");
?>
--FILE--
<?php
include_once "connect.inc";
$tmp = NULL;
$link = NULL;
// NOTE: again this test does not test all of the behaviour of the function
if (NULL !== ($tmp = mysql_drop_db()))
printf("[001] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
require('table.inc');
if (!mysql_query('DROP DATABASE IF EXISTS mysqldropdb'))
printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!mysql_query('CREATE DATABASE mysqldropdb'))
die(sprintf("[005] Skipping, can't create test database. [%d] %s\n",
mysql_errno($link), mysql_error($link)));
if (true !== ($tmp = mysql_drop_db('mysqldropdb', $link)))
printf("[006] Can't drop, got %s/%s. [%d] %s\n",
gettype($tmp), $tmp,
mysql_errno($link), mysql_error($link));
if (false !== ($tmp = mysql_drop_db('mysqldropdb', $link)))
printf("[007] Expecting boolean/false, got %s/%s. [%d] %s\n",
gettype($tmp), $tmp,
mysql_errno($link), mysql_error($link));
mysql_close($link);
print "done!\n";
?>
--EXPECTF--
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_client_info.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_get_client_info.phpt
+++ php-src/ext/mysql/tests/mysql_get_client_info.phpt
--TEST--
mysql_get_client_info()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
include "connect.inc";
if (!is_string($info = mysql_get_client_info()) || ('' === $info))
printf("[001] Expecting string/any_non_empty, got %s/%s\n",
gettype($info), $info);
if (ini_get('unicode.semantics') && !is_unicode($info)) {
printf("[002] Expecting Unicode!\n");
var_inspect($info);
}
print "done!";
?>
--EXPECTF--
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_host_info.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_get_host_info.phpt
+++ php-src/ext/mysql/tests/mysql_get_host_info.phpt
--TEST--
mysql_get_host_info()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
include_once "connect.inc";
if (false !== ($tmp = @mysql_get_host_info(NULL)))
printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
require "table.inc";
if (!is_string($info = mysql_get_host_info($link)) || ('' === $info))
printf("[003] Expecting string/any_non_empty, got %s/%s\n",
gettype($info), $info);
$def_info = mysql_get_host_info();
if ($def_info !== $info) {
printf("[004] Host info for the default link and the specified link
differ, [%d] %s\n",
mysql_errno(), mysql_error());
var_dump($def_info);
var_dump($info);
}
if (ini_get('unicode.semantics') && !is_unicode($info)) {
printf("[005] Expecting Unicode error message!\n");
var_inspect($info);
}
print "done!";
?>
--EXPECTF--
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_proto_info.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_get_proto_info.phpt
+++ php-src/ext/mysql/tests/mysql_get_proto_info.phpt
--TEST--
mysql_get_proto_info()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
include_once "connect.inc";
if (false !== ($tmp = @mysql_get_proto_info(NULL)))
printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
require "table.inc";
if (!is_int($info = mysql_get_proto_info($link)) || (0 === $info))
printf("[003] Expecting int/any_non_empty, got %s/%s\n",
gettype($info), $info);
print "done!";
?>
--EXPECTF--
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_get_server_info.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_get_server_info.phpt
+++ php-src/ext/mysql/tests/mysql_get_server_info.phpt
--TEST--
mysql_get_server_info()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
include "connect.inc";
if (false !== ($tmp = @mysql_get_server_info(NULL)))
printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
require "table.inc";
if (!is_string($info = mysql_get_server_info($link)) || ('' === $info))
printf("[003] Expecting string/any_non_empty, got %s/%s\n",
gettype($info), $info);
$def_info = mysql_get_server_info();
if ($def_info !== $info) {
printf("[004] Server info for the default link and the specified link
differ, [%d] %s\n",
mysql_errno(), mysql_error());
var_dump($def_info);
var_dump($info);
}
if (ini_get('unicode.semantics') && !is_unicode($info)) {
printf("[005] Expecting Unicode error message!\n");
var_inspect($info);
}
print "done!";
?>
--EXPECTF--
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_info.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_info.phpt
+++ php-src/ext/mysql/tests/mysql_info.phpt
--TEST--
mysql_info()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
include "connect.inc";
if (false !== ($tmp = @mysql_info()))
printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
if (NULL !== ($tmp = @mysql_info(NULL)))
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
require "table.inc";
if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (100, "a")',
$link))
printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (false !== ($tmp = mysql_info($link)))
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (101, "a"),
(102, "b")', $link))
printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
printf("[006] Expecting string/any_non_empty, got %s/%s\n",
gettype($tmp), $tmp);
if (!$res = mysql_query('INSERT INTO test(id, label) SELECT id + 200, label
FROM test', $link))
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
printf("[008] Expecting string/any_non_empty, got %s/%s\n",
gettype($tmp), $tmp);
if (!$res = mysql_query('ALTER TABLE test MODIFY label CHAR(2)', $link))
printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
printf("[010] Expecting string/any_non_empty, got %s/%s\n",
gettype($tmp), $tmp);
if (!$res = mysql_query('UPDATE test SET label = "b" WHERE id >= 100',
$link))
printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link));
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
printf("[012] Expecting string/any_non_empty, got %s/%s\n",
gettype($tmp), $tmp);
if (ini_get('unicode.semantics') && !is_unicode($tmp)) {
printf("[013] Expecting Unicode!\n");
var_inspect($info);
}
if (!is_string($def_tmp = mysql_info()) || ('' == $def_tmp))
printf("[014] Expecting string/any_non_empty, got %s/%s\n",
gettype($def_tmp), $def_tmp);
if ($def_tmp !== $tmp) {
printf("[015] Results differ for default link and specified link, [%d]
%s\n",
mysql_errno(), mysql_error());
var_inspect($tmp);
var_inspect($def_tmp);
}
// NOTE: no LOAD DATA INFILE test
print "done!";
?>
--EXPECTF--
done!
http://cvs.php.net/viewvc.cgi/php-src/ext/mysql/tests/mysql_insert_id.phpt?view=markup&rev=1.1
Index: php-src/ext/mysql/tests/mysql_insert_id.phpt
+++ php-src/ext/mysql/tests/mysql_insert_id.phpt
--TEST--
mysql_insert_id()
--SKIPIF--
<?php require_once('skipif.inc'); ?>
<?php require_once('skipifemb.inc'); ?>
--FILE--
<?php
include "connect.inc";
$tmp = NULL;
$link = NULL;
if (false !== ($tmp = @mysql_insert_id()))
printf("[001] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
if (false !== ($tmp = @mysql_insert_id($link)))
printf("[002] Expecting boolean/false, got %s/%s\n", gettype($tmp),
$tmp);
require('table.inc');
if (0 !== ($tmp = mysql_insert_id($link)))
printf("[003] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1",
$link)) {
printf("[004] [%d] %s\n", mysql_errno($link), mysql_error($link));
}
if (0 !== ($tmp = mysql_insert_id($link)))
printf("[005] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
mysql_free_result($res);
// no auto_increment column
if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (100, 'a')",
$link)) {
printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
}
if (0 !== ($tmp = mysql_insert_id($link)))
printf("[007] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
if (!$res = mysql_query("ALTER TABLE test MODIFY id INT NOT NULL
AUTO_INCREMENT", $link)) {
printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
}
if (!$res = mysql_query("INSERT INTO test(label) VALUES ('a')", $link)) {
printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link));
}
if (0 === ($tmp = mysql_insert_id($link)))
printf("[010] Expecting int/0, got %s/%s\n", gettype($tmp), $tmp);
mysql_close($link);
var_dump(mysql_insert_id($link));
print "done!";
?>
--EXPECTF--
Warning: mysql_insert_id(): %d is not a valid MySQL-Link resource in %s on line
%d
bool(false)
done!
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php