Skip to content

Commit 7e5171d

Browse files
Clean up mysqli tests (#15473)
1 parent d472866 commit 7e5171d

File tree

102 files changed

+192
-314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+192
-314
lines changed

ext/mysqli/tests/065.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ require_once 'skipifconnectfailure.inc';
1616
printf("[002] Cannot set SQL-Mode, [%d] %s\n", mysqli_errno($mysql), mysqli_error($mysql));
1717

1818
$esc_str = chr(0xbf) . chr(0x5c);
19-
$len = $charset = array();
20-
$tmp = null;
2119

2220
if ($mysql->set_charset("latin1")) {
2321
/* 5C should be escaped */

ext/mysqli/tests/071.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ require_once 'skipifconnectfailure.inc';
1111
require_once 'connect.inc';
1212

1313
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
14-
$version = $mysql->server_version;
1514

1615
var_dump($mysql->query('DO 1'));
1716

ext/mysqli/tests/bug45289.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require_once 'skipifconnectfailure.inc';
2424
if (!$stmt->bind_param('i', $id) || !$stmt->execute())
2525
printf("[003] [%d] %s\n", $stmt->errno, $stmt->error);
2626

27-
if ($res = $link->store_result()) {
27+
if ($link->store_result()) {
2828
printf("[004] Can store result!\n");
2929
} else {
3030
printf("[004] [%d] %s\n", $link->errno, $link->error);

ext/mysqli/tests/bug55283.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ $link->close();
4343
--FILE--
4444
<?php
4545
require_once 'connect.inc';
46-
$db1 = new mysqli();
47-
4846

4947
$flags = MYSQLI_CLIENT_SSL | MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
5048

ext/mysqli/tests/bug62885.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ try {
1616
echo $e->getMessage() . \PHP_EOL;
1717
}
1818

19-
$test2 = array();
2019
$test2 = array();
2120
try {
2221
$test1 = mysqli_poll($test2, $test3, $tablica, 0);

ext/mysqli/tests/bug66124.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ $table_create = "CREATE TABLE `test` (
1616

1717
$table_insert = "INSERT INTO `test` SET `id`=?";
1818
$table_select = "SELECT * FROM `test`";
19-
$table_delete = "DELETE FROM `test`";
2019
$id = '1311200011005001566';
2120

2221

ext/mysqli/tests/bug72489.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ while ($stmt->fetch()) {
4545

4646
echo "Finished 1\n";
4747

48-
$newArray = array();
49-
5048
echo "Finished 2\n";
5149

5250
?>

ext/mysqli/tests/bug76386.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ $link->query('INSERT INTO t_test VALUES ();');
6767
$stmt = $link->prepare('SELECT * FROM t_test;');
6868
if ($stmt) {
6969
$stmt->execute();
70-
$tid = $t = $t2 = $t3 = $t4 = null;
70+
$tid = $t = $t2 = $t4 = null;
7171
$stmt->bind_result($tid, $t, $t2, $t4, $t6);
7272
while ($stmt->fetch()) {
7373
var_dump($t, $t2, $t4, $t6);

ext/mysqli/tests/fetch/mysqli_fetch_all_data_types_variation.phpt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ function func_mysqli_fetch_all(
4444
$tmp = mysqli_fetch_all($result, MYSQLI_BOTH);
4545
$row = $tmp[0];
4646

47-
$fields = mysqli_fetch_fields($result);
48-
4947
if ($regexp_comparison) {
5048
if (!preg_match($regexp_comparison, (string)$row['label']) || !preg_match($regexp_comparison, (string)$row[1])) {
5149
printf("[%04d] Expecting %s/%s [reg exp = %s], got %s/%s resp. %s/%s. [%d] %s\n", $offset + 4,

ext/mysqli/tests/gh14255.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ mysqli_report(MYSQLI_REPORT_STRICT|MYSQLI_REPORT_ERROR);
1616
$mysqli = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket);
1717

1818
$ca = $mysqli->query('SELECT 1 ');
19-
$c = $ca->fetch_assoc();
19+
$ca->fetch_assoc();
2020
try {
2121
$mysqli->query('SELECT non_existent_column');
2222
} catch (Exception $e) {
2323
echo "Caught exception"."\n";
2424
}
25-
$c = $ca->fetch_assoc();
25+
$ca->fetch_assoc();
2626

2727
print "done!";
2828
?>

ext/mysqli/tests/gh9841.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $mysqli->real_query("SELECT (
3333
UNION ALL
3434
SELECT 2
3535
) FROM dual");
36-
$result = new mysqli_result($mysqli);
36+
new mysqli_result($mysqli);
3737

3838
// now make sure the errors are thrown when not using silent mode
3939
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
@@ -65,7 +65,7 @@ $mysqli->real_query("SELECT (
6565
SELECT 2
6666
) FROM dual");
6767
try {
68-
$result = new mysqli_result($mysqli);
68+
new mysqli_result($mysqli);
6969
} catch (mysqli_sql_exception $e) {
7070
echo $e->getMessage()."\n";
7171
}

ext/mysqli/tests/mysqli_affected_rows.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ mysqli
7878
if (1 !== ($tmp = mysqli_affected_rows($link)))
7979
printf("[025] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
8080

81-
$charsets = array('utf8');
82-
foreach ($charsets as $k => $charset) {
81+
foreach (['utf8'] as $charset) {
8382
if (!($res = mysqli_query($link, sprintf("SHOW CHARACTER SET LIKE '%s'", $charset))))
8483
continue;
8584
mysqli_free_result($res);

ext/mysqli/tests/mysqli_begin_transaction.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (!have_innodb($link))
3131

3232
/* overrule autocommit */
3333
if (true !== ($tmp = mysqli_begin_transaction($link)))
34-
printf("[011] Got %s - [%d] %s\n", var_dump($tmp, true), mysqli_errno($link), mysqli_error($link));
34+
printf("[011] Got %s - [%d] %s\n", $tmp, mysqli_errno($link), mysqli_error($link));
3535

3636
if (!mysqli_query($link, 'INSERT INTO test(id) VALUES (1)'))
3737
printf("[012] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
@@ -72,7 +72,7 @@ if (!have_innodb($link))
7272
} else if (!mysqli_commit($link)) {
7373
printf("[018] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
7474
} else {
75-
$res = mysqli_query($link, "SELECT id FROM test WHERE id = 2");
75+
mysqli_query($link, "SELECT id FROM test WHERE id = 2");
7676
}
7777
}
7878

ext/mysqli/tests/mysqli_change_user_new.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ if (mysqli_get_server_version($link) >= 10_00_00)
2020
<?php
2121
require_once 'connect.inc';
2222

23-
$tmp = NULL;
24-
$link = NULL;
25-
2623
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
2724
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
2825
$host, $user, $db, $port, $socket);

ext/mysqli/tests/mysqli_change_user_old.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@ if (mysqli_get_server_version($link) >= 50600 && mysqli_get_server_version($link
1717
<?php
1818
require_once 'connect.inc';
1919

20-
$tmp = NULL;
21-
$link = NULL;
22-
2320
if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
2421
printf("[006] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",
2522
$host, $user, $db, $port, $socket);

ext/mysqli/tests/mysqli_change_user_oo.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ if (mysqli_get_server_version($link) >= 50600)
1515
<?php
1616
require_once 'connect.inc';
1717

18-
$link = NULL;
19-
$tmp = NULL;
20-
2118
$mysqli = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
2219

2320
if (false !== ($tmp = $mysqli->change_user($user . '_unknown_really', $passwd . 'non_empty', $db)))

ext/mysqli/tests/mysqli_change_user_rollback.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if (!have_innodb($link))
3030
$num = $row['_num'];
3131
assert($num > 0);
3232

33-
if (!$res = mysqli_query($link, 'DELETE FROM test'))
33+
if (false === mysqli_query($link, 'DELETE FROM test'))
3434
printf("[004] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
3535

3636
if (!$res = mysqli_query($link, 'SELECT COUNT(*) AS _num FROM test'))

ext/mysqli/tests/mysqli_class_mysqli_properties_no_conn.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require_once 'skipifconnectfailure.inc';
1515
printf("\nClass variables:\n");
1616
$variables = array_keys(get_class_vars(get_class($mysqli)));
1717
sort($variables);
18-
foreach ($variables as $k => $var) {
18+
foreach ($variables as $var) {
1919
try {
2020
printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
2121
} catch (Error $exception) {
@@ -25,7 +25,7 @@ require_once 'skipifconnectfailure.inc';
2525

2626
printf("\nObject variables:\n");
2727
$variables = array_keys(get_object_vars($mysqli));
28-
foreach ($variables as $k => $var) {
28+
foreach ($variables as $var) {
2929
try {
3030
printf("%s = '%s'\n", $var, var_export($mysqli->$var, true));
3131
} catch (Error $exception) {

ext/mysqli/tests/mysqli_class_mysqli_result_interface.phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,12 @@ require_once 'skipifconnectfailure.inc';
6969
printf("\nClass variables:\n");
7070
$variables = array_keys(get_class_vars(get_class($mysqli_result)));
7171
sort($variables);
72-
foreach ($variables as $k => $var)
72+
foreach ($variables as $var)
7373
printf("%s\n", $var);
7474

7575
printf("\nObject variables:\n");
7676
$variables = array_keys(get_object_vars($mysqli_result));
77-
foreach ($variables as $k => $var)
77+
foreach ($variables as $var)
7878
printf("%s\n", $var);
7979

8080
printf("\nMagic, magic properties:\n");
@@ -121,9 +121,9 @@ require_once 'skipifconnectfailure.inc';
121121
if (!mysqli_query($link, "SELECT id FROM test ORDER BY id"))
122122
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
123123

124-
$res = new mysqli_result($link);
125-
$res = new mysqli_result($link, MYSQLI_STORE_RESULT);
126-
$res = new mysqli_result($link, MYSQLI_USE_RESULT);
124+
new mysqli_result($link);
125+
new mysqli_result($link, MYSQLI_STORE_RESULT);
126+
new mysqli_result($link, MYSQLI_USE_RESULT);
127127

128128
$valid = array(MYSQLI_STORE_RESULT, MYSQLI_USE_RESULT);
129129
do {
@@ -132,7 +132,7 @@ require_once 'skipifconnectfailure.inc';
132132

133133
if ($TEST_EXPERIMENTAL) {
134134
ob_start();
135-
$res = new mysqli_result($link, $mode);
135+
new mysqli_result($link, $mode);
136136
$content = ob_get_contents();
137137
ob_end_clean();
138138
if (!stristr($content, 'Invalid value for resultmode'))

ext/mysqli/tests/mysqli_class_mysqli_stmt_interface.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ mysqli
6868
printf("\nClass variables:\n");
6969
$variables = array_keys(get_class_vars(get_class($stmt)));
7070
sort($variables);
71-
foreach ($variables as $k => $var)
71+
foreach ($variables as $var)
7272
printf("%s\n", $var);
7373

7474
printf("\nObject variables:\n");
7575
$variables = array_keys(get_object_vars($stmt));
76-
foreach ($variables as $k => $var)
76+
foreach ($variables as $var)
7777
printf("%s\n", $var);
7878

7979
printf("\nMagic, magic properties:\n");

ext/mysqli/tests/mysqli_connect.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ require_once 'skipifconnectfailure.inc';
1010
<?php
1111
require_once 'connect.inc';
1212

13-
$tmp = NULL;
14-
$link = NULL;
15-
1613
/* we need to check, if the server allows anonymous login (empty user) */
1714
$tmp = @mysqli_connect('localhost');
1815
$anon_allow = (gettype($tmp) == "object");
1916

2017
$exptype = ($anon_allow) ? "mysqli_object" : "false";
2118

19+
$link = NULL;
2220
$tmp = @mysqli_connect($link);
2321
if (($anon_allow && gettype($tmp) != "object") || (!$anon_allow && $tmp != false)) {
2422
printf("[002] Expecting %s, got %s/%s\n", $exptype, gettype($tmp), $tmp);

ext/mysqli/tests/mysqli_connect_attr.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ mysqli_close($link);
3737
<?php
3838
require_once 'connect.inc';
3939

40-
$tmp = NULL;
41-
$link = NULL;
42-
$res = NULL;
4340
if (!$link = mysqli_connect($host, $user, $passwd, $db, $port, $socket))
4441
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n",$host, $user, $db, $port, $socket);
4542

ext/mysqli/tests/mysqli_connect_errno.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require_once 'skipifconnectfailure.inc';
1010
<?php
1111
require_once 'connect.inc';
1212

13-
$tmp = NULL;
1413
$link = NULL;
1514

1615
// too many parameter

ext/mysqli/tests/mysqli_connect_error.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ require_once 'skipifconnectfailure.inc';
1010
<?php
1111
require_once 'connect.inc';
1212

13-
$tmp = NULL;
1413
$link = NULL;
1514

1615
// too many parameter
@@ -29,7 +28,7 @@ require_once 'skipifconnectfailure.inc';
2928

3029
mysqli_close($link);
3130

32-
if ($link = @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
31+
if (false !== @my_mysqli_connect($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket))
3332
printf("[003] Connect to the server should fail using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
3433
$host, $user . 'unknown_really', $db, $port, $socket);
3534

ext/mysqli/tests/mysqli_connect_oo.phpt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ require_once 'skipifconnectfailure.inc';
1010
<?php
1111
require_once 'connect.inc';
1212

13-
$tmp = NULL;
14-
$link = NULL;
15-
16-
$obj = new stdClass();
17-
1813
if ($mysqli = new mysqli($host, $user . 'unknown_really', $passwd . 'non_empty', $db, $port, $socket) && !mysqli_connect_errno())
1914
printf("[003] Can connect to the server using host=%s, user=%s, passwd=***non_empty, dbname=%s, port=%s, socket=%s\n",
2015
$host, $user . 'unknown_really', $db, $port, $socket);

ext/mysqli/tests/mysqli_connect_oo_defaults.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ require_once 'skipifconnectfailure.inc';
1010
<?php
1111
require_once 'connect.inc';
1212

13-
$tmp = NULL;
14-
$link = NULL;
15-
1613
if ($socket != "")
1714
/* mysqli.default_socket requires non-empty string */
1815
ini_set('mysqli.default_socket', 'socket');

ext/mysqli/tests/mysqli_constants.phpt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ $expected_constants['MYSQLI_STORE_RESULT_COPY_DATA'] = true;
107107

108108
$expected_constants['MYSQLI_REFRESH_BACKUP_LOG'] = true;
109109

110-
$version = 50007 + 1;
111110
$expected_constants['MYSQLI_OPT_NET_CMD_BUFFER_SIZE'] = true;
112111
$expected_constants['MYSQLI_OPT_NET_READ_BUFFER_SIZE'] = true;
113112
$expected_constants['MYSQLI_ASYNC'] = true;
@@ -154,7 +153,7 @@ $expected_constants["MYSQLI_TYPE_JSON"] = true;
154153

155154
$unexpected_constants = array();
156155

157-
foreach ($constants as $group => $consts) {
156+
foreach ($constants as $consts) {
158157
foreach ($consts as $name => $value) {
159158
if (stristr($name, 'mysqli')) {
160159
$name = strtoupper($name);

ext/mysqli/tests/mysqli_debug_control_string.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if (defined('MYSQLI_DEBUG_TRACE_ENABLED') && !MYSQLI_DEBUG_TRACE_ENABLED)
3131
return false;
3232
}
3333

34-
if (!$res = mysqli_query($link, 'SELECT * FROM test')) {
34+
if (false === mysqli_query($link, 'SELECT * FROM test')) {
3535
printf("[%03d][control string '%s'] [%d] %s.\n",
3636
$offset + 2,
3737
$control_string,

0 commit comments

Comments
 (0)