@@ -54,10 +54,10 @@ public function __construct(array $mockedNamespaces = array())
54
54
55
55
$ warn = false ;
56
56
foreach ($ mockedNamespaces as $ type => $ namespaces ) {
57
- if (!is_array ($ namespaces )) {
57
+ if (!\ is_array ($ namespaces )) {
58
58
$ namespaces = array ($ namespaces );
59
59
}
60
- if (is_int ($ type )) {
60
+ if (\ is_int ($ type )) {
61
61
// @deprecated BC with v2.8 to v3.0
62
62
$ type = 'time-sensitive ' ;
63
63
$ warn = true ;
@@ -107,10 +107,10 @@ public function startTestSuite($suite)
107
107
$ this ->testsWithWarnings = array ();
108
108
109
109
foreach ($ suite ->tests () as $ test ) {
110
- if (!($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase)) {
110
+ if (!($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase)) {
111
111
continue ;
112
112
}
113
- if (null === $ Test ::getPreserveGlobalStateSettings (get_class ($ test ), $ test ->getName (false ))) {
113
+ if (null === $ Test ::getPreserveGlobalStateSettings (\ get_class ($ test ), $ test ->getName (false ))) {
114
114
$ test ->setPreserveGlobalState (false );
115
115
}
116
116
}
@@ -148,10 +148,10 @@ public function startTestSuite($suite)
148
148
continue ;
149
149
}
150
150
$ groups = $ Test ::getGroups ($ test ->getName ());
151
- if (in_array ('time-sensitive ' , $ groups , true )) {
151
+ if (\ in_array ('time-sensitive ' , $ groups , true )) {
152
152
ClockMock::register ($ test ->getName ());
153
153
}
154
- if (in_array ('dns-sensitive ' , $ groups , true )) {
154
+ if (\ in_array ('dns-sensitive ' , $ groups , true )) {
155
155
DnsMock::register ($ test ->getName ());
156
156
}
157
157
}
@@ -160,7 +160,7 @@ public function startTestSuite($suite)
160
160
} elseif (2 === $ this ->state ) {
161
161
$ skipped = array ();
162
162
foreach ($ suite ->tests () as $ test ) {
163
- if (!($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase)
163
+ if (!($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase)
164
164
|| isset ($ this ->wasSkipped [$ suiteName ]['* ' ])
165
165
|| isset ($ this ->wasSkipped [$ suiteName ][$ test ->getName ()])) {
166
166
$ skipped [] = $ test ;
@@ -173,8 +173,8 @@ public function startTestSuite($suite)
173
173
public function addSkippedTest ($ test , \Exception $ e , $ time )
174
174
{
175
175
if (0 < $ this ->state ) {
176
- if ($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase) {
177
- $ class = get_class ($ test );
176
+ if ($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase) {
177
+ $ class = \ get_class ($ test );
178
178
$ method = $ test ->getName ();
179
179
} else {
180
180
$ class = $ test ->getName ();
@@ -187,7 +187,7 @@ public function addSkippedTest($test, \Exception $e, $time)
187
187
188
188
public function startTest ($ test )
189
189
{
190
- if (-2 < $ this ->state && ($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase)) {
190
+ if (-2 < $ this ->state && ($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase)) {
191
191
if (null !== $ test ->getTestResultObject ()) {
192
192
$ this ->reportUselessTests = $ test ->getTestResultObject ()->isStrictAboutTestsThatDoNotTestAnything ();
193
193
}
@@ -205,25 +205,25 @@ public function startTest($test)
205
205
$ Test = 'PHPUnit\Util\Test ' ;
206
206
$ AssertionFailedError = 'PHPUnit\Framework\AssertionFailedError ' ;
207
207
}
208
- $ groups = $ Test ::getGroups (get_class ($ test ), $ test ->getName (false ));
208
+ $ groups = $ Test ::getGroups (\ get_class ($ test ), $ test ->getName (false ));
209
209
210
210
if (!$ this ->runsInSeparateProcess ) {
211
- if (in_array ('time-sensitive ' , $ groups , true )) {
212
- ClockMock::register (get_class ($ test ));
211
+ if (\ in_array ('time-sensitive ' , $ groups , true )) {
212
+ ClockMock::register (\ get_class ($ test ));
213
213
ClockMock::withClockMock (true );
214
214
}
215
- if (in_array ('dns-sensitive ' , $ groups , true )) {
216
- DnsMock::register (get_class ($ test ));
215
+ if (\ in_array ('dns-sensitive ' , $ groups , true )) {
216
+ DnsMock::register (\ get_class ($ test ));
217
217
}
218
218
}
219
219
220
- $ annotations = $ Test ::parseTestMethodAnnotations (get_class ($ test ), $ test ->getName (false ));
220
+ $ annotations = $ Test ::parseTestMethodAnnotations (\ get_class ($ test ), $ test ->getName (false ));
221
221
222
222
if (isset ($ annotations ['class ' ]['expectedDeprecation ' ])) {
223
223
$ test ->getTestResultObject ()->addError ($ test , new $ AssertionFailedError ('`@expectedDeprecation` annotations are not allowed at the class level. ' ), 0 );
224
224
}
225
225
if (isset ($ annotations ['method ' ]['expectedDeprecation ' ])) {
226
- if (!in_array ('legacy ' , $ groups , true )) {
226
+ if (!\ in_array ('legacy ' , $ groups , true )) {
227
227
$ this ->error = new $ AssertionFailedError ('Only tests with the `@group legacy` annotation can have `@expectedDeprecation`. ' );
228
228
}
229
229
@@ -237,7 +237,7 @@ public function startTest($test)
237
237
238
238
public function addWarning ($ test , $ e , $ time )
239
239
{
240
- if ($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase) {
240
+ if ($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase) {
241
241
$ this ->testsWithWarnings [$ test ->getName ()] = true ;
242
242
}
243
243
}
@@ -253,7 +253,7 @@ public function endTest($test, $time)
253
253
$ BaseTestRunner = 'PHPUnit\Runner\BaseTestRunner ' ;
254
254
$ Warning = 'PHPUnit\Framework\Warning ' ;
255
255
}
256
- $ className = get_class ($ test );
256
+ $ className = \ get_class ($ test );
257
257
$ classGroups = $ Test ::getGroups ($ className );
258
258
$ groups = $ Test ::getGroups ($ className , $ test ->getName (false ));
259
259
@@ -274,7 +274,7 @@ public function endTest($test, $time)
274
274
foreach ($ deprecations ? unserialize ($ deprecations ) : array () as $ deprecation ) {
275
275
$ error = serialize (array ('deprecation ' => $ deprecation [1 ], 'class ' => $ className , 'method ' => $ test ->getName (false ), 'triggering_file ' => isset ($ deprecation [2 ]) ? $ deprecation [2 ] : null ));
276
276
if ($ deprecation [0 ]) {
277
- trigger_error ($ error , E_USER_DEPRECATED );
277
+ @ trigger_error ($ error , E_USER_DEPRECATED );
278
278
} else {
279
279
@trigger_error ($ error , E_USER_DEPRECATED );
280
280
}
@@ -283,13 +283,13 @@ public function endTest($test, $time)
283
283
}
284
284
285
285
if ($ this ->expectedDeprecations ) {
286
- if (!in_array ($ test ->getStatus (), array ($ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE ), true )) {
287
- $ test ->addToAssertionCount (count ($ this ->expectedDeprecations ));
286
+ if (!\ in_array ($ test ->getStatus (), array ($ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE ), true )) {
287
+ $ test ->addToAssertionCount (\ count ($ this ->expectedDeprecations ));
288
288
}
289
289
290
290
restore_error_handler ();
291
291
292
- if (!$ errored && !in_array ($ test ->getStatus (), array ($ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE , $ BaseTestRunner ::STATUS_FAILURE , $ BaseTestRunner ::STATUS_ERROR ), true )) {
292
+ if (!$ errored && !\ in_array ($ test ->getStatus (), array ($ BaseTestRunner ::STATUS_SKIPPED , $ BaseTestRunner ::STATUS_INCOMPLETE , $ BaseTestRunner ::STATUS_FAILURE , $ BaseTestRunner ::STATUS_ERROR ), true )) {
293
293
try {
294
294
$ prefix = "@expectedDeprecation: \n" ;
295
295
$ test ->assertStringMatchesFormat ($ prefix .'%A ' .implode ("\n%A " , $ this ->expectedDeprecations )."\n%A " , $ prefix .' ' .implode ("\n " , $ this ->gatheredDeprecations )."\n" );
@@ -303,24 +303,24 @@ public function endTest($test, $time)
303
303
$ this ->expectedDeprecations = $ this ->gatheredDeprecations = array ();
304
304
$ this ->previousErrorHandler = null ;
305
305
}
306
- if (!$ this ->runsInSeparateProcess && -2 < $ this ->state && ($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase)) {
307
- if (in_array ('time-sensitive ' , $ groups , true )) {
306
+ if (!$ this ->runsInSeparateProcess && -2 < $ this ->state && ($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase)) {
307
+ if (\ in_array ('time-sensitive ' , $ groups , true )) {
308
308
ClockMock::withClockMock (false );
309
309
}
310
- if (in_array ('dns-sensitive ' , $ groups , true )) {
310
+ if (\ in_array ('dns-sensitive ' , $ groups , true )) {
311
311
DnsMock::withMockedHosts (array ());
312
312
}
313
313
}
314
314
315
- if (($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase) && 0 === strpos ($ test ->getName (), 'testLegacy ' ) && !isset ($ this ->testsWithWarnings [$ test ->getName ()]) && !in_array ('legacy ' , $ groups , true )) {
315
+ if (($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase) && 0 === strpos ($ test ->getName (), 'testLegacy ' ) && !isset ($ this ->testsWithWarnings [$ test ->getName ()]) && !\ in_array ('legacy ' , $ groups , true )) {
316
316
$ result = $ test ->getTestResultObject ();
317
317
318
318
if (method_exists ($ result , 'addWarning ' )) {
319
319
$ result ->addWarning ($ test , new $ Warning ('Using the "testLegacy" prefix to mark tests as legacy is deprecated since version 3.3 and will be removed in 4.0. Use the "@group legacy" notation instead to add the test to the legacy group. ' ), $ time );
320
320
}
321
321
}
322
322
323
- if (($ test instanceof \PHPUnit_Framework_TestCase || $ test instanceof TestCase) && strpos ($ className , '\Legacy ' ) && !isset ($ this ->testsWithWarnings [$ test ->getName ()]) && !in_array ('legacy ' , $ classGroups , true )) {
323
+ if (($ test instanceof \PHPUnit \ Framework \TestCase || $ test instanceof TestCase) && strpos ($ className , '\Legacy ' ) && !isset ($ this ->testsWithWarnings [$ test ->getName ()]) && !\ in_array ('legacy ' , $ classGroups , true )) {
324
324
$ result = $ test ->getTestResultObject ();
325
325
326
326
if (method_exists ($ result , 'addWarning ' )) {
@@ -339,7 +339,7 @@ public function handleError($type, $msg, $file, $line, $context = array())
339
339
// If the message is serialized we need to extract the message. This occurs when the error is triggered by
340
340
// by the isolated test path in \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest().
341
341
$ parsedMsg = @unserialize ($ msg );
342
- if (is_array ($ parsedMsg )) {
342
+ if (\ is_array ($ parsedMsg )) {
343
343
$ msg = $ parsedMsg ['deprecation ' ];
344
344
}
345
345
if (error_reporting ()) {
0 commit comments