xref: /PHP-7.2/ext/interbase/tests/008.phpt (revision 17ccbeec)
1--TEST--
2InterBase: event handling
3--SKIPIF--
4<?php
5if (PHP_OS == "WINNT") echo "skip";
6include("skipif.inc");
7?>
8--FILE--
9<?php
10
11require("interbase.inc");
12
13$count = 0;
14
15function event_callback($event)
16{
17	global $count;
18	if ($event == 'TEST1') echo "FAIL TEST1\n";
19	return (++$count < 5); /* cancel event */
20}
21
22$link = ibase_connect($test_base);
23
24ibase_query("CREATE PROCEDURE pevent AS BEGIN POST_EVENT 'TEST1'; POST_EVENT 'TEST2'; END");
25ibase_commit();
26
27$e = ibase_set_event_handler('event_callback','TEST1');
28ibase_free_event_handler($e);
29
30ibase_set_event_handler('event_callback','TEST2');
31
32usleep(5E+5);
33
34for ($i = 0; $i < 8; ++$i) {
35	ibase_query("EXECUTE PROCEDURE pevent");
36	ibase_commit();
37
38	usleep(3E+5);
39}
40
41usleep(5E+5);
42
43if (!$count || $count > 5) echo "FAIL ($count)\n";
44echo "end of test\n";
45
46?>
47--EXPECT--
48end of test
49