Skip to content

Commit f0835c0

Browse files
willfitchdsp
authored andcommitted
Bug #62593 Added test for change
1 parent 7ea4f73 commit f0835c0

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

ext/pdo_pgsql/tests/bug62593.phpt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
--TEST--
2+
PDO PgSQL Bug #62593 (Emulate prepares behave strangely with PARAM_BOOL)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('pdo') || !extension_loaded('pdo_pgsql')) die('skip not loaded');
6+
require dirname(__FILE__) . '/config.inc';
7+
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
8+
PDOTest::skip();
9+
?>
10+
--FILE--
11+
<?php
12+
require dirname(__FILE__) . '/../../../ext/pdo/tests/pdo_test.inc';
13+
$db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
14+
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
15+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
16+
$errors = array();
17+
18+
$query = $db->prepare('SELECT :foo IS FALSE as val_is_false');
19+
$query->bindValue(':foo', true, PDO::PARAM_BOOL);
20+
$query->execute();
21+
$errors[] = $query->errorInfo();
22+
23+
$query->bindValue(':foo', 0, PDO::PARAM_BOOL);
24+
$query->execute();
25+
$errors[] = $query->errorInfo();
26+
27+
$query->bindValue(':foo', false, PDO::PARAM_BOOL);
28+
$query->execute();
29+
$errors[] = $query->errorInfo();
30+
31+
$expect = 'No errors found';
32+
33+
foreach ($errors as $error)
34+
{
35+
if (strpos('Invalid text representation', $error[2]) !== false)
36+
{
37+
$expect = 'Invalid boolean found';
38+
}
39+
}
40+
echo $expect;
41+
?>
42+
--EXPECTF--
43+
44+
No errors found

0 commit comments

Comments
 (0)