@@ -61,24 +61,27 @@ public function testDefinitions()
61
61
62
62
public function testCreateDeprecatedService ()
63
63
{
64
- $ definition = new Definition ('stdClass ' );
65
- $ definition ->setDeprecated (true );
64
+ $ deprecations = array ();
65
+ set_error_handler (function ($ type , $ msg ) use (&$ deprecations ) {
66
+ if (E_USER_DEPRECATED !== $ type ) {
67
+ restore_error_handler ();
66
68
67
- $ that = $ this ;
68
- $ wasTriggered = false ;
69
+ return call_user_func_array ( ' PHPUnit_Util_ErrorHandler::handleError ' , func_get_args ()) ;
70
+ }
69
71
70
- set_error_handler (function ($ errno , $ errstr ) use ($ that , &$ wasTriggered ) {
71
- $ that ->assertSame (E_USER_DEPRECATED , $ errno );
72
- $ that ->assertSame ('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed. ' , $ errstr );
73
- $ wasTriggered = true ;
72
+ $ deprecations [] = $ msg ;
74
73
});
75
74
75
+ $ definition = new Definition ('stdClass ' );
76
+ $ definition ->setDeprecated (true );
77
+
76
78
$ builder = new ContainerBuilder ();
77
79
$ builder ->createService ($ definition , 'deprecated_foo ' );
78
80
79
81
restore_error_handler ();
80
82
81
- $ this ->assertTrue ($ wasTriggered );
83
+ $ this ->assertCount (1 , $ deprecations );
84
+ $ this ->assertContains ('The "deprecated_foo" service is deprecated. You should stop using it, as it will soon be removed. ' , $ deprecations [0 ]);
82
85
}
83
86
84
87
public function testRegister ()
0 commit comments