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