Skip to content

Commit 36cb551

Browse files
committed
Support cleaning up errors with xp::gc() inside tests
1 parent 44ed49b commit 36cb551

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/php/test/execution/TestCase.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function expecting(Expect $expectation) {
5656
*/
5757
public function run($arguments= []) {
5858
$warnings= [];
59+
\xp::gc();
5960
set_error_handler(function($kind, $message, $file, $line) use(&$warnings) {
6061
$warnings[]= [$kind, $message, $file, $line];
6162
__error($kind, $message, $file, $line);
@@ -71,7 +72,7 @@ public function run($arguments= []) {
7172

7273
if ($this->expectation) {
7374
return new Failed($name, 'Did not catch expected '.$this->expectation->pattern(), null);
74-
} else if ($warnings) {
75+
} else if (\xp::$errors) {
7576
\xp::gc();
7677
return new Failed($name, 'Succeeded but raised '.sizeof($warnings).' warning(s)', new Warnings($warnings));
7778
} else {

0 commit comments

Comments
 (0)