xref: /PHP-8.3/Zend/tests/assert/expect_011.phpt (revision 482985ca)
1--TEST--
2test overloaded __toString on custom exception
3--INI--
4zend.assertions=1
5assert.exception=1
6--FILE--
7<?php
8class MyExpectations extends AssertionError {
9    public function __toString() {
10        return sprintf(
11            "[Message]: %s", __CLASS__);
12    }
13}
14
15class One {
16    public function __construct() {
17        assert(false, (string) new MyExpectations());
18    }
19}
20class Two extends One {}
21
22new Two();
23?>
24--EXPECTF--
25Fatal error: Uncaught AssertionError: [Message]: MyExpectations in %sexpect_011.php:%d
26Stack trace:
27#0 %sexpect_011.php(%d): assert(false, '[Message]: MyEx...')
28#1 %sexpect_011.php(%d): One->__construct()
29#2 {main}
30  thrown in %sexpect_011.php on line %d
31