Skip to content

Commit a0091b9

Browse files
committed
Add test for PDO
1 parent 70c2e4c commit a0091b9

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
--TEST--
2+
PDO Common: TypeError when binding an object as a boolean which cannot be converted
3+
--EXTENSIONS--
4+
pdo
5+
gmp
6+
--SKIPIF--
7+
<?php
8+
$dir = getenv('REDIR_TEST_DIR');
9+
if (false == $dir) die('skip no driver');
10+
require_once $dir . 'pdo_test.inc';
11+
PDOTest::skip();
12+
?>
13+
--FILE--
14+
<?php
15+
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
16+
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
17+
$db = PDOTest::factory();
18+
19+
$db->exec('CREATE TABLE test(id int NOT NULL PRIMARY KEY, val boolean)');
20+
$db->exec('INSERT INTO test VALUES(1, 1)');
21+
$db->exec('INSERT INTO test VALUES(2, 0)');
22+
23+
$gmp = gmp_init('20', 10);
24+
25+
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
26+
$s = $db->prepare('SELECT id FROM test WHERE val = :bool');
27+
$s->bindValue(':bool', $gmp, PDO::PARAM_BOOL);
28+
29+
try {
30+
$s->execute();
31+
} catch (\TypeError $e) {
32+
echo $e->getMessage(), \PHP_EOL;
33+
}
34+
?>
35+
==DONE==
36+
--EXPECT--
37+
==DONE==

0 commit comments

Comments
 (0)