1--TEST--
2Observer: Basic observability of userland functions with uncaught exceptions
3--EXTENSIONS--
4zend_test
5--INI--
6zend_test.observer.enabled=1
7zend_test.observer.show_output=1
8zend_test.observer.observe_all=1
9--FILE--
10<?php
11function foo()
12{
13    static $callCount = 0;
14    echo 'Call #' . $callCount . PHP_EOL;
15    if (++$callCount == 3) {
16        throw new RuntimeException('Third time is a charm');
17    }
18}
19
20foo();
21foo();
22foo();
23
24echo 'You should not see this' . PHP_EOL;
25?>
26--EXPECTF--
27<!-- init '%s%eobserver_exception_%d.php' -->
28<file '%s%eobserver_exception_%d.php'>
29  <!-- init foo() -->
30  <foo>
31Call #0
32  </foo>
33  <foo>
34Call #1
35  </foo>
36  <foo>
37Call #2
38    <!-- Exception: RuntimeException -->
39  </foo>
40  <!-- Exception: RuntimeException -->
41</file '%s%eobserver_exception_%d.php'>
42
43Fatal error: Uncaught RuntimeException: Third time is a charm in %s%eobserver_exception_%d.php:%d
44Stack trace:
45#0 %s%eobserver_exception_%d.php(%d): foo()
46#1 {main}
47  thrown in %s%eobserver_exception_%d.php on line %d
48