summaryrefslogtreecommitdiff
path: root/ext/pgsql/tests
diff options
context:
space:
mode:
authorGeorge Peter Banyard <girgias@php.net>2020-09-13 05:31:01 +0200
committerGeorge Peter Banyard <girgias@php.net>2020-09-14 17:01:35 +0200
commitd0111d785df10de3eacf41716aff27e579ab67e8 (patch)
treebb8d536102cecd48202997308bf2bddce62d327e /ext/pgsql/tests
parent96f2f3174bb7d3c5367b5a48817f485cef5ed71b (diff)
downloadphp-git-d0111d785df10de3eacf41716aff27e579ab67e8.tar.gz
Promote warnings to Errors in PostgreSQL extension
Do some drive by indentation fixes Also fix pg_select() in regards to the $result_type arg which was missing from ZPP Closes GH-6129
Diffstat (limited to 'ext/pgsql/tests')
-rw-r--r--ext/pgsql/tests/09notice.phpt10
-rw-r--r--ext/pgsql/tests/bug60244.phpt41
-rw-r--r--ext/pgsql/tests/pg_insert_002.phpt9
-rw-r--r--ext/pgsql/tests/pg_select_001.phpt11
4 files changed, 48 insertions, 23 deletions
diff --git a/ext/pgsql/tests/09notice.phpt b/ext/pgsql/tests/09notice.phpt
index 11c80481f6..2b4df446d8 100644
--- a/ext/pgsql/tests/09notice.phpt
+++ b/ext/pgsql/tests/09notice.phpt
@@ -42,7 +42,11 @@ var_dump(pg_last_notice($db, PGSQL_NOTICE_LAST));
var_dump(pg_last_notice($db, PGSQL_NOTICE_ALL));
// Invalid option
-var_dump(pg_last_notice($db, 99));
+try {
+ var_dump(pg_last_notice($db, 99));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
?>
--EXPECTF--
resource(%d) of type (pgsql result)
@@ -68,6 +72,4 @@ bool(true)
string(0) ""
array(0) {
}
-
-Warning: pg_last_notice(): Invalid option specified (99) in %s%e09notice.php on line %d
-bool(false)
+pg_last_notice(): Argument #2 ($option) must be one of PGSQL_NOTICE_LAST, PGSQL_NOTICE_ALL, or PGSQL_NOTICE_CLEAR
diff --git a/ext/pgsql/tests/bug60244.phpt b/ext/pgsql/tests/bug60244.phpt
index 94568b6031..4d2f4cbcd7 100644
--- a/ext/pgsql/tests/bug60244.phpt
+++ b/ext/pgsql/tests/bug60244.phpt
@@ -12,10 +12,26 @@ include 'config.inc';
$db = pg_connect($conn_str);
$result = pg_query("select 'a' union select 'b'");
-var_dump(pg_fetch_array($result, -1));
-var_dump(pg_fetch_assoc($result, -1));
-var_dump(pg_fetch_object($result, -1));
-var_dump(pg_fetch_row($result, -1));
+try {
+ var_dump(pg_fetch_array($result, -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(pg_fetch_assoc($result, -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(pg_fetch_object($result, -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+try {
+ var_dump(pg_fetch_row($result, -1));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
var_dump(pg_fetch_array($result, 0));
var_dump(pg_fetch_assoc($result, 0));
@@ -25,18 +41,11 @@ var_dump(pg_fetch_row($result, 0));
pg_close($db);
?>
---EXPECTF--
-Warning: pg_fetch_array(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
-bool(false)
-
-Warning: pg_fetch_assoc(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
-bool(false)
-
-Warning: pg_fetch_object(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
-bool(false)
-
-Warning: pg_fetch_row(): The row parameter must be greater or equal to zero in %sbug60244.php on line %d
-bool(false)
+--EXPECT--
+pg_fetch_array(): Argument #2 ($row_number) must be greater than or equal to 0
+pg_fetch_assoc(): Argument #2 ($row_number) must be greater than or equal to 0
+pg_fetch_object(): Argument #2 ($row_number) must be greater than or equal to 0
+pg_fetch_row(): Argument #2 ($row_number) must be greater than or equal to 0
array(2) {
[0]=>
string(1) "a"
diff --git a/ext/pgsql/tests/pg_insert_002.phpt b/ext/pgsql/tests/pg_insert_002.phpt
index bb84a00d0d..0aa6395cfa 100644
--- a/ext/pgsql/tests/pg_insert_002.phpt
+++ b/ext/pgsql/tests/pg_insert_002.phpt
@@ -10,13 +10,16 @@ include('config.inc');
$conn = pg_connect($conn_str);
foreach (array('', '.', '..') as $table) {
- var_dump(pg_insert($conn, $table, array('id' => 1, 'id2' => 1)));
+ try {
+ var_dump(pg_insert($conn, $table, array('id' => 1, 'id2' => 1)));
+ } catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+ }
}
?>
Done
--EXPECTF--
-Warning: pg_insert(): The table name must be specified in %s on line %d
-bool(false)
+pg_insert(): Argument #2 ($table_name) cannot be empty
Warning: pg_insert(): The table name must be specified in %s on line %d
bool(false)
diff --git a/ext/pgsql/tests/pg_select_001.phpt b/ext/pgsql/tests/pg_select_001.phpt
index 9bcf130dd8..803cf1fbbf 100644
--- a/ext/pgsql/tests/pg_select_001.phpt
+++ b/ext/pgsql/tests/pg_select_001.phpt
@@ -31,6 +31,8 @@ var_dump(pg_select($conn, 'phptests.bar', array('id' => 1)));
/* Existent column */
var_dump(pg_select($conn, 'phptests.bar', array('id4' => 4)));
+/* Use a different result type */
+var_dump(pg_select($conn, 'phptests.bar', array('id4' => 4), 0, PGSQL_NUM));
pg_query('DROP TABLE phptests.foo');
pg_query('DROP TABLE phptests.bar');
@@ -61,3 +63,12 @@ array(1) {
string(1) "5"
}
}
+array(1) {
+ [0]=>
+ array(2) {
+ [0]=>
+ string(1) "4"
+ [1]=>
+ string(1) "5"
+ }
+}