Skip to content

Commit

Permalink
Reindent more mysqli tests
Browse files Browse the repository at this point in the history
Due to a bug in the tidy script, most tests did not actually get
reindented...
  • Loading branch information
nikic committed Nov 25, 2020
1 parent 97d192b commit e3e67b7
Show file tree
Hide file tree
Showing 374 changed files with 17,809 additions and 17,809 deletions.
94 changes: 47 additions & 47 deletions ext/mysqli/tests/001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,55 @@ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
require_once("connect.inc");

$test = "";

/*** test mysqli_connect localhost:port ***/
$link = my_mysqli_connect($host, $user, $passwd, "", $port, $socket);
$test .= ($link) ? "1" : "0";
mysqli_close($link);

/*** test mysqli_real_connect ***/
$link = mysqli_init();
$test.= (my_mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) )
? "1" : "0";
mysqli_close($link);

/*** test mysqli_real_connect with db ***/
$link = mysqli_init();
$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
? "1" : "0";
mysqli_close($link);

/*** test mysqli_real_connect with port ***/
$link = mysqli_init();
$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
? "1":"0";
mysqli_close($link);

/* temporary addition for Kent's setup, Win32 box */
for ($i = 0; $i < 10; $i++) {
if (!$link = mysqli_init())
printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());

if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());

mysqli_close($link);
}

/*** test mysqli_real_connect compressed ***/
/*
$link = mysqli_init();
$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS))
? "1" : "0";
mysqli_close($link);
require_once("connect.inc");

$test = "";

/*** test mysqli_connect localhost:port ***/
$link = my_mysqli_connect($host, $user, $passwd, "", $port, $socket);
$test .= ($link) ? "1" : "0";
mysqli_close($link);

/*** test mysqli_real_connect ***/
$link = mysqli_init();
$test.= (my_mysqli_real_connect($link, $host, $user, $passwd, "", $port, $socket) )
? "1" : "0";
mysqli_close($link);

/*** test mysqli_real_connect with db ***/
$link = mysqli_init();
$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
? "1" : "0";
mysqli_close($link);

/*** test mysqli_real_connect with port ***/
$link = mysqli_init();
$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
? "1":"0";
mysqli_close($link);

/* temporary addition for Kent's setup, Win32 box */
for ($i = 0; $i < 10; $i++) {
if (!$link = mysqli_init())
printf("[001 + %d] mysqli_init() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());

if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket))
printf("[002 + %d] mysqli_real_connect() failed, [%d] %s\n", $i, mysqli_connect_errno(), mysqli_connect_error());

mysqli_close($link);
}

/*** test mysqli_real_connect compressed ***/
/*
$link = mysqli_init();
$test .= (my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, MYSQLI_CLIENT_COMPRESS))
? "1" : "0";
mysqli_close($link);
*/
/* todo ssl connections */
/* todo ssl connections */

var_dump($test);
print "done!";
var_dump($test);
print "done!";
?>
--EXPECTF--
%s(4) "1111"
Expand Down
56 changes: 28 additions & 28 deletions ext/mysqli/tests/002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,44 +7,44 @@ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
require_once("connect.inc");
require_once("connect.inc");

/*** test mysqli_connect 127.0.0.1 ***/
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());
/*** test mysqli_connect 127.0.0.1 ***/
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
printf("[001] [%d] %s\n", mysqli_connect_errno(), mysqli_connect_error());

if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null"))
printf("[002] Cannot drop table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$rc = mysqli_query($link,"CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint,
col3 int, col4 bigint,
col5 float, col6 double,
col7 date, col8 time,
col9 varbinary(10),
col10 varchar(50),
col11 char(20)) ENGINE=" . $engine);
$rc = mysqli_query($link,"CREATE TABLE test_fetch_null(col1 tinyint, col2 smallint,
col3 int, col4 bigint,
col5 float, col6 double,
col7 date, col8 time,
col9 varbinary(10),
col10 varchar(50),
col11 char(20)) ENGINE=" . $engine);

if (!$rc)
printf("[003] Cannot create table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$rc)
printf("[003] Cannot create table, [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$rc = mysqli_query($link, "INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)");
if (!$rc)
printf("[004] Cannot insert records, [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "INSERT INTO test_fetch_null(col1,col10, col11) VALUES(1,'foo1', 1000),(2,'foo2', 88),(3,'foo3', 389789)");
if (!$rc)
printf("[004] Cannot insert records, [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null ORDER BY col1");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
mysqli_stmt_execute($stmt);
$stmt = mysqli_prepare($link, "SELECT col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11 from test_fetch_null ORDER BY col1");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7, $c8, $c9, $c10, $c11);
mysqli_stmt_execute($stmt);

mysqli_stmt_fetch($stmt);
mysqli_stmt_fetch($stmt);

$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7,$c8,$c9,$c10,$c11);

var_dump($test);
var_dump($test);

mysqli_stmt_close($stmt);
@mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null");
mysqli_close($link);
print "done!";
mysqli_stmt_close($stmt);
@mysqli_query($link, "DROP TABLE IF EXISTS test_fetch_null");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
Expand Down
106 changes: 53 additions & 53 deletions ext/mysqli/tests/003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,70 +7,70 @@ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
require_once("connect.inc");
require_once("connect.inc");

$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);

mysqli_query($link, "SET sql_mode=''");
mysqli_query($link, "SET sql_mode=''");

if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_result"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp(14),
c4 year,
c5 datetime,
c6 timestamp(4),
c7 timestamp(6)) ENGINE=" . $engine);
$rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp(14),
c4 year,
c5 datetime,
c6 timestamp(4),
c7 timestamp(6)) ENGINE=" . $engine);

/*
Seems that not all MySQL 6.0 installations use defaults that ignore the display widths.
From the manual:
From MySQL 4.1.0 on, TIMESTAMP display format differs from that of earlier MySQL releases:
[...]
Display widths (used as described in the preceding section) are no longer supported.
In other words, for declarations such as TIMESTAMP(2), TIMESTAMP(4), and so on,
the display width is ignored.
[...]
*/
if (!$rc)
$rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp,
c4 year,
c5 datetime,
c6 timestamp,
c7 timestamp) ENGINE=" . $engine);
/*
Seems that not all MySQL 6.0 installations use defaults that ignore the display widths.
From the manual:
From MySQL 4.1.0 on, TIMESTAMP display format differs from that of earlier MySQL releases:
[...]
Display widths (used as described in the preceding section) are no longer supported.
In other words, for declarations such as TIMESTAMP(2), TIMESTAMP(4), and so on,
the display width is ignored.
[...]
*/
if (!$rc)
$rc = @mysqli_query($link,"CREATE TABLE test_bind_result(
c1 date,
c2 time,
c3 timestamp,
c4 year,
c5 datetime,
c6 timestamp,
c7 timestamp) ENGINE=" . $engine);

if (!$rc)
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$rc)
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$rc = mysqli_query($link, "INSERT INTO test_bind_result VALUES(
'2002-01-02',
'12:49:00',
'2002-01-02 17:46:59',
2010,
'2010-07-10',
'2020','1999-12-29')");
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
$rc = mysqli_query($link, "INSERT INTO test_bind_result VALUES(
'2002-01-02',
'12:49:00',
'2002-01-02 17:46:59',
2010,
'2010-07-10',
'2020','1999-12-29')");
if (!$rc)
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);
$stmt = mysqli_prepare($link, "SELECT c1, c2, c3, c4, c5, c6, c7 FROM test_bind_result");
mysqli_stmt_bind_result($stmt, $c1, $c2, $c3, $c4, $c5, $c6, $c7);
mysqli_stmt_execute($stmt);
mysqli_stmt_fetch($stmt);

$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);
$test = array($c1,$c2,$c3,$c4,$c5,$c6,$c7);

var_dump($test);
var_dump($test);

mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
mysqli_close($link);
print "done!";
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_result");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
Expand Down
62 changes: 31 additions & 31 deletions ext/mysqli/tests/004.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -7,48 +7,48 @@ require_once('skipifconnectfailure.inc');
?>
--FILE--
<?php
include ("connect.inc");
include ("connect.inc");

/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
/*** test mysqli_connect 127.0.0.1 ***/
$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);

mysqli_select_db($link, $db);
mysqli_select_db($link, $db);

if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link,"DROP TABLE IF EXISTS test_bind_fetch"))
printf("[001] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text) ENGINE=" . $engine))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link,"CREATE TABLE test_bind_fetch(c1 char(10), c2 text) ENGINE=" . $engine))
printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567890', 'this is a test0')"))
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567891', 'this is a test1')"))
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')"))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567892', 'this is a test2')"))
printf("[005] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')"))
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!mysqli_query($link, "INSERT INTO test_bind_fetch VALUES ('1234567893', 'this is a test3')"))
printf("[006] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

if (!$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1"))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
if (!$stmt = mysqli_prepare($link, "SELECT * FROM test_bind_fetch ORDER BY c1"))
printf("[007] [%d] %s\n", mysqli_errno($link), mysqli_error($link));

$c1 = $c2 = NULL;
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
$i = 4;
while ($i--) {
mysqli_stmt_fetch($stmt);
$test = array($c1, $c2);
var_dump($test);
}
$c1 = $c2 = NULL;
mysqli_stmt_bind_result($stmt, $c1, $c2);
mysqli_stmt_execute($stmt);
$i = 4;
while ($i--) {
mysqli_stmt_fetch($stmt);
$test = array($c1, $c2);
var_dump($test);
}

mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
mysqli_stmt_close($stmt);
mysqli_query($link, "DROP TABLE IF EXISTS test_bind_fetch");
mysqli_close($link);
print "done!";
?>
--CLEAN--
<?php
Expand Down

0 comments on commit e3e67b7

Please sign in to comment.