xref: /PHP-5.3/ext/pgsql/tests/80_bug36625.phpt (revision 610c7fbe)
1--TEST--
2Bug #36625 (pg_trace() does not work)
3--SKIPIF--
4<?php
5require_once('skipif.inc');
6?>
7--FILE--
8<?php
9
10require_once('config.inc');
11
12$dbh = @pg_connect($conn_str);
13if (!$dbh) {
14	die ('Could not connect to the server');
15}
16
17$tracefile = dirname(__FILE__) . '/trace.tmp';
18
19@unlink($tracefile);
20var_dump(file_exists($tracefile));
21
22pg_trace($tracefile, 'w', $dbh);
23$res = pg_query($dbh, 'select 1');
24var_dump($res);
25pg_close($dbh);
26
27$found = 0;
28function search_trace_file($line)
29{
30	if (strpos($line, '"select 1"') !== false || strpos($line, "'select 1'") !== false) {
31		$GLOBALS['found']++;
32	}
33}
34
35$trace = file($tracefile);
36array_walk($trace, 'search_trace_file');
37var_dump($found > 0);
38var_dump(file_exists($tracefile));
39
40?>
41===DONE===
42--CLEAN--
43<?php unlink($tracefile); ?>
44--EXPECTF--
45bool(false)
46resource(%d) of type (pgsql result)
47bool(true)
48bool(true)
49===DONE===
50