xref: /PHP-7.4/ext/pdo/tests/bug_50458.phpt (revision 26dfce7f)
1--TEST--
2PDO Common: Bug #50458 (PDO::FETCH_FUNC fails with Closures)
3--SKIPIF--
4<?php
5if (!extension_loaded('pdo')) die('skip');
6$dir = getenv('REDIR_TEST_DIR');
7if (false == $dir) die('skip no driver');
8require_once $dir . 'pdo_test.inc';
9PDOTest::skip();
10?>
11--FILE--
12<?php
13if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
14require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
15
16$db = PDOTest::factory();
17$db->exec("CREATE TABLE test (a VARCHAR(10))");
18$db->exec("INSERT INTO test (a) VALUES ('xyz')");
19$res = $db->query("SELECT a FROM test");
20var_dump($res->fetchAll(PDO::FETCH_FUNC, function($a) { return strtoupper($a); }));
21
22?>
23===DONE===
24--EXPECT--
25array(1) {
26  [0]=>
27  string(3) "XYZ"
28}
29===DONE===
30