tests: blacklist sqlite3_str and sqlite3_win32 functions
[m6w6/ext-psi] / tests / sqlite / sqlite001.phpt
1 --TEST--
2 sqlite3
3 --INI--
4 psi.directory={PWD}:{PWD}/../../psi.d
5 psi.blacklist.decls="sqlite3_str*,sqlite3_*serialize,sqlite3_stmt_scanstatus*,sqlite3_snapshot*,sqlite3_win32*"
6 --SKIPIF--
7 <?php
8 extension_loaded("psi") or printf("%s\n", "skip - need ext/psi");
9 function_exists("sqlite3\\open") or printf("%s\n", "skip - need libsqlite3");
10 ?>
11 --FILE--
12 ===TEST===
13 <?php
14
15 var_dump(sqlite3\version());
16
17 copy(__DIR__."/sqlite001.db", __DIR__."/sqlite001.tmp");
18
19 $rc = sqlite3\open(__DIR__."/sqlite001.tmp", $db);
20 if ($rc) {
21 printf("%s\n", sqlite3\errstr($rc));
22 }
23
24 function callback($context, int $argc, array $argv, array $cols) {
25 $context->row = $context->row ?? 0;
26
27 for ($i = 0; $i < $argc; ++$i) {
28 printf("%d: %s = %s\n", $context->row, $cols[$i], $argv[$i] ?? "<NULL>");
29 }
30 printf("\n");
31 ++$context->row;
32 }
33
34 $rc = sqlite3\exec($db, "SELECT * FROM test", "callback", new stdClass, $error);
35 if ($rc) {
36 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
37 }
38
39 $rc = sqlite3\exec($db, "INSERT INTO test VALUES (3,'three')", "callback", new stdClass, $error);
40 if ($rc) {
41 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
42 }
43
44 $rc = sqlite3\exec($db, "SELECT * FROM test", "callback", new stdClass, $error);
45 if ($rc) {
46 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
47 }
48
49 $rc = sqlite3\exec($db, "SELECT *", "callback", new stdClass, $error);
50 if ($rc) {
51 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
52 }
53
54 sqlite3\close($db);
55
56 $rc = sqlite3\exec($db, "SELECT *", "callback", new stdClass, $error);
57 if ($rc) {
58 printf("%s: '%s'\n", sqlite3\errstr($rc), $error);
59 }
60
61 ?>
62 ===DONE===
63 --EXPECTF--
64 ===TEST===
65 string(%d) "3.%d.%s"
66 0: id = 1
67 0: data = one
68
69 1: id = 2
70 1: data = two
71
72 0: id = 1
73 0: data = one
74
75 1: id = 2
76 1: data = two
77
78 2: id = 3
79 2: data = three
80
81 SQL logic error%s
82 %s: ''
83 ===DONE===
84 --CLEAN--
85 <?php
86 @unlink(__DIR__."/sqlite001.tmp");
87 ?>