xref: /php-src/ext/pgsql/tests/gh17165.phpt (revision 171cc5c6)
1--TEST--
2Fix pg_query()/pg_query_params()/pg_prepare()/pg_execute()/pg_set_error_verbosity()/pg_set_client_encoding()/pg_put_line() pg field infos calls ArgumentCountError message.
3--EXTENSIONS--
4pgsql
5--SKIPIF--
6<?php
7include("inc/skipif.inc");
8?>
9--FILE--
10<?php
11
12
13include "inc/config.inc";
14
15$db = pg_connect($conn_str);
16try {
17    pg_query("a", "b", "c");
18} catch (ArgumentCountError $e) {
19    echo $e->getMessage(), PHP_EOL;
20}
21
22try {
23    pg_query_params($db, "b", array(), "d");
24} catch (ArgumentCountError $e) {
25    echo $e->getMessage(), PHP_EOL;
26}
27
28try {
29    pg_prepare($db, "a", "b", "c");
30} catch (ArgumentCountError $e) {
31    echo $e->getMessage(), PHP_EOL;
32}
33
34try {
35    pg_set_error_verbosity($db, 0, PHP_INT_MAX);
36} catch (ArgumentCountError $e) {
37    echo $e->getMessage(), PHP_EOL;
38}
39
40try {
41    pg_set_client_encoding($db, "foo", "bar");
42} catch (ArgumentCountError $e) {
43    echo $e->getMessage(), PHP_EOL;
44}
45
46try {
47    pg_put_line($db, "my", "data");
48} catch (ArgumentCountError $e) {
49    echo $e->getMessage(), PHP_EOL;
50}
51
52try {
53    pg_field_is_null($db, false, "myfield", new stdClass());
54} catch (ArgumentCountError $e) {
55    echo $e->getMessage(), PHP_EOL;
56}
57?>
58--EXPECT--
59pg_query() expects at most 2 arguments, 3 given
60pg_query_params() expects at most 3 arguments, 4 given
61pg_prepare() expects at most 3 arguments, 4 given
62pg_set_error_verbosity() expects at most 2 arguments, 3 given
63pg_set_client_encoding() expects at most 2 arguments, 3 given
64pg_put_line() expects at most 2 arguments, 3 given
65pg_field_is_null() expects at most 3 arguments, 4 given
66