From 09587d3cbf2e8a7e00c2706a697ad7572b54897a Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Fri, 25 Dec 2009 20:56:00 +0000 Subject: [PATCH] - Updated ext/pgsql tests to work w/ PostgreSQL 8.5 # tested w/ 8.5alpha3 --- ext/pgsql/tests/10pg_convert.phpt | 5 ++- ext/pgsql/tests/10pg_convert_85.phpt | 29 ++++++++++++++++++ ext/pgsql/tests/12pg_insert.phpt | 5 ++- ext/pgsql/tests/12pg_insert_85.phpt | 24 +++++++++++++++ ext/pgsql/tests/13pg_select.phpt | 5 ++- ext/pgsql/tests/13pg_select_85.phpt | 37 ++++++++++++++++++++++ ext/pgsql/tests/14pg_update.phpt | 5 ++- ext/pgsql/tests/14pg_update_85.phpt | 25 +++++++++++++++ ext/pgsql/tests/bug37100.phpt | 5 ++- ext/pgsql/tests/bug37100_85.phpt | 46 ++++++++++++++++++++++++++++ ext/pgsql/tests/skipif.inc | 15 ++++++++- 11 files changed, 195 insertions(+), 6 deletions(-) create mode 100644 ext/pgsql/tests/10pg_convert_85.phpt create mode 100644 ext/pgsql/tests/12pg_insert_85.phpt create mode 100644 ext/pgsql/tests/13pg_select_85.phpt create mode 100644 ext/pgsql/tests/14pg_update_85.phpt create mode 100644 ext/pgsql/tests/bug37100_85.phpt diff --git a/ext/pgsql/tests/10pg_convert.phpt b/ext/pgsql/tests/10pg_convert.phpt index b88b8e5798..73bf2b64e8 100644 --- a/ext/pgsql/tests/10pg_convert.phpt +++ b/ext/pgsql/tests/10pg_convert.phpt @@ -1,7 +1,10 @@ --TEST-- PostgreSQL pg_convert() --SKIPIF-- - +='); +?> --FILE-- +--FILE-- +'1234', 'str'=>'AAA', 'bin'=>'BBB'); +$converted = pg_convert($db, $table_name, $fields); + +var_dump($converted); +?> +--EXPECT-- +array(3) { + ["num"]=> + string(4) "1234" + ["str"]=> + string(5) "'AAA'" + ["bin"]=> + string(11) "'\\x424242'" +} diff --git a/ext/pgsql/tests/12pg_insert.phpt b/ext/pgsql/tests/12pg_insert.phpt index 8d98f220fd..f5cd868f81 100644 --- a/ext/pgsql/tests/12pg_insert.phpt +++ b/ext/pgsql/tests/12pg_insert.phpt @@ -1,7 +1,10 @@ --TEST-- PostgreSQL pg_insert() --SKIPIF-- - +='); +?> --FILE-- +--FILE-- +'1234', 'str'=>'AAA', 'bin'=>'BBB'); + +pg_insert($db, $table_name, $fields) or print "Error in test 1\n"; +echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n"; + +echo "Ok\n"; +?> +--EXPECT-- +INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','\\x424242'); +Ok diff --git a/ext/pgsql/tests/13pg_select.phpt b/ext/pgsql/tests/13pg_select.phpt index 55e88db731..f1504a8b17 100644 --- a/ext/pgsql/tests/13pg_select.phpt +++ b/ext/pgsql/tests/13pg_select.phpt @@ -1,7 +1,10 @@ --TEST-- PostgreSQL pg_select() --SKIPIF-- - +='); +?> --FILE-- +--FILE-- +'1234', 'str'=>'ABC', 'bin'=>'XYZ'); +$ids = array('num'=>'1234'); + +$res = pg_select($db, $table_name, $ids) or print "Error\n"; +var_dump($res); +echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n"; +echo "Ok\n"; + +?> +--EXPECT-- +array(1) { + [0]=> + array(3) { + ["num"]=> + string(4) "1234" + ["str"]=> + string(3) "AAA" + ["bin"]=> + string(8) "\x424242" + } +} +SELECT * FROM php_pgsql_test WHERE num=1234; +Ok diff --git a/ext/pgsql/tests/14pg_update.phpt b/ext/pgsql/tests/14pg_update.phpt index ef8d7e49bd..b41dd1af84 100644 --- a/ext/pgsql/tests/14pg_update.phpt +++ b/ext/pgsql/tests/14pg_update.phpt @@ -1,7 +1,10 @@ --TEST-- PostgreSQL pg_update() --SKIPIF-- - +='); +?> --FILE-- +--FILE-- +'1234', 'str'=>'ABC', 'bin'=>'XYZ'); +$ids = array('num'=>'1234'); + +pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n"; +echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n"; + +echo "Ok\n"; +?> +--EXPECT-- +UPDATE php_pgsql_test SET num=1234,str='ABC',bin='\\x58595a' WHERE num=1234; +Ok diff --git a/ext/pgsql/tests/bug37100.phpt b/ext/pgsql/tests/bug37100.phpt index b66149e4a5..fa6b9ba9e0 100644 --- a/ext/pgsql/tests/bug37100.phpt +++ b/ext/pgsql/tests/bug37100.phpt @@ -1,7 +1,10 @@ --TEST-- Bug #37100 (data is returned truncated with BINARY CURSOR) --SKIPIF-- - +='); +?> --FILE-- +--FILE-- + +--EXPECT-- +string(14) "\x0103aa000812" +string(12) "0103aa000812" +int(6) +string(12) "0103aa000812" diff --git a/ext/pgsql/tests/skipif.inc b/ext/pgsql/tests/skipif.inc index 043a0bd8d2..74b27b3ad8 100644 --- a/ext/pgsql/tests/skipif.inc +++ b/ext/pgsql/tests/skipif.inc @@ -15,4 +15,17 @@ $conn = @pg_connect($conn_str); if (!is_resource($conn)) { die("skip could not connect\n"); } -?> \ No newline at end of file + +function skip_server_version($version, $op = '<') { _skip_version('server', $version, $op); } +function skip_client_version($version, $op = '<') { _skip_version('client', $version, $op); } + + +function _skip_version($type, $version, $op) +{ + $pg = pg_parameter_status($type.'_version'); + if (version_compare($pg, $version, $op)) { + die("skip {$type} version {$pg} is {$op} {$version}\n"); + } +} + +?> -- 2.40.0