xref: /php-src/ext/pgsql/tests/inc/skipif.inc (revision c15988aa)
1
2<?php
3// This script prints "skip" unless:
4// * the pgsql extension is built-in or loadable, AND
5// * there is a database called "test" accessible
6//   with no username/password, AND
7// * we have create/drop privileges on the entire "test"
8//   database
9
10include("config.inc");
11include("lcmess.inc");
12
13if (getenv("SKIP_REPEAT")) {
14    // pgsql tests are order-dependent.
15    // We should probably change that, but in the meantime do not allow repetition.
16    die("skip Cannot repeat pgsql tests");
17}
18$conn = @pg_connect($conn_str);
19if (!$conn) {
20    die("skip could not connect\n");
21}
22
23function skip_server_version($version, $op = '<')
24{
25    global $conn;
26    $pg = pg_parameter_status($conn,'server_version');
27    if (version_compare($pg, $version, $op)) {
28        die("skip Server version {$pg} is {$op} {$version}\n");
29    }
30    return $pg;
31}
32
33function skip_bytea_not_hex()
34{
35    global $conn;
36    $out = pg_escape_bytea($conn, "\xFF");
37    if (strpos($out, '377') !== false) {
38        die("skip libpq or backend < 9.0\n");
39    }
40}
41
42function skip_bytea_not_escape()
43{
44    global $conn;
45    $out = pg_escape_bytea($conn, "\xFF");
46    if (strpos($out, '377') === false) {
47        die("skip libpq or backend >= 9.0\n");
48    }
49}
50
51?>
52