Skip to content

Commit 7c8df1c

Browse files
committed
fix testing deprecation messages
* always restore the previous error handler * throw `LogicExcetion` when unexpected error type is triggered
1 parent 3114efd commit 7c8df1c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,20 +519,24 @@ public function testAliasDefinitionContainsUnsupportedElements()
519519

520520
$deprecations = array();
521521
set_error_handler(function ($type, $msg) use (&$deprecations) {
522-
if (E_USER_DEPRECATED === $type) {
523-
$deprecations[] = $msg;
522+
if (E_USER_DEPRECATED !== $type) {
523+
restore_error_handler();
524+
525+
return call_user_func_array('PHPUnit_Util_ErrorHandler::handleError', func_get_args());
524526
}
527+
528+
$deprecations[] = $msg;
525529
});
526530

527531
$loader->load('legacy_invalid_alias_definition.xml');
528532

533+
restore_error_handler();
534+
529535
$this->assertTrue($container->has('bar'));
530536

531537
$this->assertCount(3, $deprecations);
532538
$this->assertContains('Using the attribute "class" is deprecated for alias definition "bar"', $deprecations[0]);
533539
$this->assertContains('Using the element "tag" is deprecated for alias definition "bar"', $deprecations[1]);
534540
$this->assertContains('Using the element "factory" is deprecated for alias definition "bar"', $deprecations[2]);
535-
536-
restore_error_handler();
537541
}
538542
}

0 commit comments

Comments
 (0)