diff options
| author | Matteo Beccati <mbeccati@php.net> | 2009-12-25 20:56:00 +0000 |
|---|---|---|
| committer | Matteo Beccati <mbeccati@php.net> | 2009-12-25 20:56:00 +0000 |
| commit | 09587d3cbf2e8a7e00c2706a697ad7572b54897a (patch) | |
| tree | f5e94a87dccdf4f8a90af177094d1c5781bbb737 | |
| parent | 42d05a5c020929db37856d2076b5e1a3b51a62d5 (diff) | |
| download | php-git-09587d3cbf2e8a7e00c2706a697ad7572b54897a.tar.gz | |
- Updated ext/pgsql tests to work w/ PostgreSQL 8.5
# tested w/ 8.5alpha3
| -rw-r--r-- | ext/pgsql/tests/10pg_convert.phpt | 5 | ||||
| -rw-r--r-- | ext/pgsql/tests/10pg_convert_85.phpt | 29 | ||||
| -rw-r--r-- | ext/pgsql/tests/12pg_insert.phpt | 5 | ||||
| -rw-r--r-- | ext/pgsql/tests/12pg_insert_85.phpt | 24 | ||||
| -rw-r--r-- | ext/pgsql/tests/13pg_select.phpt | 5 | ||||
| -rw-r--r-- | ext/pgsql/tests/13pg_select_85.phpt | 37 | ||||
| -rw-r--r-- | ext/pgsql/tests/14pg_update.phpt | 5 | ||||
| -rw-r--r-- | ext/pgsql/tests/14pg_update_85.phpt | 25 | ||||
| -rw-r--r-- | ext/pgsql/tests/bug37100.phpt | 5 | ||||
| -rw-r--r-- | ext/pgsql/tests/bug37100_85.phpt | 46 | ||||
| -rw-r--r-- | ext/pgsql/tests/skipif.inc | 15 |
11 files changed, 195 insertions, 6 deletions
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-- -<?php include("skipif.inc"); ?> +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '>='); +?> --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/pgsql/tests/10pg_convert_85.phpt b/ext/pgsql/tests/10pg_convert_85.phpt new file mode 100644 index 0000000000..4f1c92bf1a --- /dev/null +++ b/ext/pgsql/tests/10pg_convert_85.phpt @@ -0,0 +1,29 @@ +--TEST-- +PostgreSQL pg_convert() (8.5+) +--SKIPIF-- +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '<'); +?> +--FILE-- +<?php +error_reporting(E_ALL); + +include 'config.inc'; + +$db = pg_connect($conn_str); + +$fields = array('num'=>'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-- -<?php include("skipif.inc"); ?> +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '>='); +?> --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/pgsql/tests/12pg_insert_85.phpt b/ext/pgsql/tests/12pg_insert_85.phpt new file mode 100644 index 0000000000..a85dea0363 --- /dev/null +++ b/ext/pgsql/tests/12pg_insert_85.phpt @@ -0,0 +1,24 @@ +--TEST-- +PostgreSQL pg_insert() (8.5+) +--SKIPIF-- +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '<'); +?> +--FILE-- +<?php +error_reporting(E_ALL); + +include 'config.inc'; + +$db = pg_connect($conn_str); +$fields = array('num'=>'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-- -<?php include("skipif.inc"); ?> +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '>='); +?> --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/pgsql/tests/13pg_select_85.phpt b/ext/pgsql/tests/13pg_select_85.phpt new file mode 100644 index 0000000000..cd9c93560c --- /dev/null +++ b/ext/pgsql/tests/13pg_select_85.phpt @@ -0,0 +1,37 @@ +--TEST-- +PostgreSQL pg_select() (8.5è+) +--SKIPIF-- +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '<'); +?> +--FILE-- +<?php +error_reporting(E_ALL); + +include 'config.inc'; + +$db = pg_connect($conn_str); +$fields = array('num'=>'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-- -<?php include("skipif.inc"); ?> +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '>='); +?> --FILE-- <?php error_reporting(E_ALL); diff --git a/ext/pgsql/tests/14pg_update_85.phpt b/ext/pgsql/tests/14pg_update_85.phpt new file mode 100644 index 0000000000..f1c77eac1d --- /dev/null +++ b/ext/pgsql/tests/14pg_update_85.phpt @@ -0,0 +1,25 @@ +--TEST-- +PostgreSQL pg_update() (8.5+) +--SKIPIF-- +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '<'); +?> +--FILE-- +<?php +error_reporting(E_ALL); + +include 'config.inc'; + +$db = pg_connect($conn_str); +$fields = array('num'=>'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-- -<?php include("skipif.inc"); ?> +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '>='); +?> --FILE-- <?php diff --git a/ext/pgsql/tests/bug37100_85.phpt b/ext/pgsql/tests/bug37100_85.phpt new file mode 100644 index 0000000000..aa2477626a --- /dev/null +++ b/ext/pgsql/tests/bug37100_85.phpt @@ -0,0 +1,46 @@ +--TEST-- +Bug #37100 (data is returned truncated with BINARY CURSOR) (8.5+) +--SKIPIF-- +<?php +include("skipif.inc"); +skip_server_version('8.5dev', '<'); +?> +--FILE-- +<?php + +include 'config.inc'; + +$db = pg_connect($conn_str); + +@pg_query('DROP TABLE test_bug'); + +pg_query('CREATE TABLE test_bug (binfield byteA) ;'); +pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))"); + + +$data = pg_query("SELECT binfield FROM test_bug"); +$res = pg_fetch_result($data,0); +var_dump($res); +var_dump(bin2hex(pg_unescape_bytea($res))); + +$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;"; + +$data = pg_query($sql); +$res = pg_fetch_result($data,0); + +var_dump(strlen($res)); +var_dump(bin2hex($res)); + +pg_close($db); + +$db = pg_connect($conn_str); +pg_query('DROP TABLE test_bug'); +pg_close($db); + + +?> +--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"); + } +} + +?> |
