Skip to content

Commit 98d61d4

Browse files
committed
Fix tests
1 parent 459e298 commit 98d61d4

9 files changed

+18
-25
lines changed

ext/pgsql/tests/05large_object.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $handle = pg_lo_open ($db, $oid, "w");
4343
$bytesWritten = pg_lo_read_all($handle);
4444
echo "\n";
4545
var_dump($bytesWritten);
46-
if (pg_last_error()) echo "pg_lo_read_all() error\n".pg_last_error();
46+
if (pg_last_error($db)) echo "pg_lo_read_all() error\n".pg_last_error();
4747
pg_lo_close($handle);
4848
pg_exec ($db, "commit");
4949

ext/pgsql/tests/08escape.phpt

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ $data = file_get_contents(FILE_NAME);
4444
$db = pg_connect($conn_str);
4545

4646
// Insert binary to DB
47-
$escaped_data = pg_escape_bytea($data);
47+
$escaped_data = pg_escape_bytea($db, $data);
4848
pg_query($db, "DELETE FROM ".$table_name." WHERE num = 10000;");
4949
$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (10000, CAST ('".$escaped_data."' AS BYTEA));";
5050
pg_query($db, $sql);
@@ -73,7 +73,7 @@ for ($i = 0; $i < 2; $i++) {
7373
// pg_escape_literal/pg_escape_identifier
7474
$before = "ABC\\ABC\'";
7575
$expect = " E'ABC\\\\ABC\\\\'''";
76-
$after = pg_escape_literal($before);
76+
$after = pg_escape_literal($db, $before);
7777
if ($expect === $after) {
7878
echo "pg_escape_literal() is Ok\n";
7979
}
@@ -86,7 +86,7 @@ else {
8686

8787
$before = "ABC\\ABC\'";
8888
$expect = "\"ABC\ABC\'\"";
89-
$after = pg_escape_identifier($before);
89+
$after = pg_escape_identifier($db, $before);
9090
if ($expect === $after) {
9191
echo "pg_escape_identifier() is Ok\n";
9292
}
@@ -104,12 +104,6 @@ pg_escape_string() is Ok
104104

105105
Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
106106
pg_escape_bytea() is Ok
107-
108-
Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
109107
pg_escape_bytea() actually works with database
110-
111-
Deprecated: pg_escape_literal(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
112108
pg_escape_literal() is Ok
113-
114-
Deprecated: pg_escape_identifier(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
115109
pg_escape_identifier() is Ok

ext/pgsql/tests/09notice.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pgsql
77

88
include("skipif.inc");
99

10-
_skip_lc_messages();
10+
_skip_lc_messages($conn);
1111

1212
?>
1313
--FILE--

ext/pgsql/tests/18pg_escape_bytea_esc.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ $db = pg_connect($conn_str);
1414
@pg_query($db, "SET bytea_output = 'escape'");
1515

1616
$image = file_get_contents(__DIR__ . '/php.gif');
17-
$esc_image = pg_escape_bytea($image);
17+
$esc_image = pg_escape_bytea($db, $image);
1818

1919
pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');');
2020
$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876');
@@ -28,6 +28,5 @@ else {
2828
echo "OK";
2929
}
3030
?>
31-
--EXPECTF--
32-
Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
31+
--EXPECT--
3332
OK

ext/pgsql/tests/18pg_escape_bytea_hex.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ $db = pg_connect($conn_str);
1717
@pg_query($db, "SET bytea_output = 'hex'");
1818

1919
$image = file_get_contents(__DIR__ . '/php.gif');
20-
$esc_image = pg_escape_bytea($image);
20+
$esc_image = pg_escape_bytea($db, $image);
2121

2222
pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');');
2323
$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876');
@@ -31,6 +31,5 @@ else {
3131
echo "OK";
3232
}
3333
?>
34-
--EXPECTF--
35-
Deprecated: pg_escape_bytea(): Automatic fetching of PostgreSQL connection is deprecated in %s on line %d
34+
--EXPECT--
3635
OK

ext/pgsql/tests/80_bug32223b.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pgsql
66
<?php
77
require_once('skipif.inc');
88

9-
_skip_lc_messages();
9+
_skip_lc_messages($conn);
1010

1111
@pg_query($conn, "CREATE LANGUAGE 'plpgsql' HANDLER plpgsql_call_handler LANCOMPILER 'PL/pgSQL'");
1212
$res = @pg_query($conn, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
@@ -30,7 +30,7 @@ if (!$dbh) {
3030
die ("Could not connect to the server");
3131
}
3232

33-
_set_lc_messages(dbh);
33+
_set_lc_messages($dbh);
3434

3535
$res = pg_query($dbh, "CREATE OR REPLACE FUNCTION test_notice() RETURNS boolean AS '
3636
begin

ext/pgsql/tests/bug46408.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require_once('config.inc');
1717
$dbh = pg_connect($conn_str);
1818
setlocale(LC_ALL, "de", "de_DE", "de_DE.ISO8859-1", "de_DE.ISO_8859-1", "de_DE.UTF-8");
1919
echo 3.5 , "\n";
20-
pg_query_params("SELECT $1::numeric", array(3.5));
20+
pg_query_params($dbh, "SELECT $1::numeric", array(3.5));
2121
pg_close($dbh);
2222

2323
echo "Done".PHP_EOL;

ext/pgsql/tests/deprecated_implicit_default_link.phpt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
PostgreSQL fetching default link automatically is deprecated
3+
--EXTENSIONS--
4+
pgsql
35
--SKIPIF--
46
<?php include("skipif.inc"); ?>
57
--FILE--
@@ -8,8 +10,8 @@ PostgreSQL fetching default link automatically is deprecated
810
include('config.inc');
911
$db = pg_connect($conn_str);
1012

11-
// We don't care about warnings or errors
12-
ini_set('error_reporting', E_DEPRECATED);
13+
// We don't care about warnings
14+
ini_set('error_reporting', E_ALL&~E_WARNING);
1315

1416
// Special cases
1517
pg_set_error_verbosity(PGSQL_ERRORS_TERSE);
@@ -18,7 +20,7 @@ pg_execute('str', []);
1820

1921
pg_lo_unlink(1);
2022
// deprecated alias 'pg_lounlink',
21-
pg_lo_open(1, '');
23+
pg_lo_open(1, 'r');
2224
// deprecated alias 'pg_loopen',
2325
pg_lo_export(1, '');
2426
// deprecated alias 'pg_loexport',

ext/pgsql/tests/lcmess.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
22

3-
function _skip_lc_messages($lc_messages = 'C')
3+
function _skip_lc_messages($conn, $lc_messages = 'C')
44
{
5-
global $conn;
65
if (!_set_lc_messages($conn, $lc_messages)) {
76
die("skip Cannot set LC_MESSAGES to '{$lc_messages}'\n");
87
}

0 commit comments

Comments
 (0)