@@ -22,6 +22,7 @@ class DeprecationTest extends TestCase
22
22
use SetUpTearDownTrait;
23
23
24
24
private static $ vendorDir ;
25
+ private static $ prefixDirsPsr4 ;
25
26
26
27
private static function getVendorDir ()
27
28
{
@@ -151,22 +152,6 @@ public function testItTakesMutesDeprecationFromPhpUnitFiles()
151
152
152
153
public function providerGetTypeDetectsSelf ()
153
154
{
154
- foreach (get_declared_classes () as $ class ) {
155
- if ('C ' === $ class [0 ] && 0 === strpos ($ class , 'ComposerAutoloaderInit ' )) {
156
- $ r = new \ReflectionClass ($ class );
157
- $ v = \dirname (\dirname ($ r ->getFileName ()));
158
- if (file_exists ($ v .'/composer/installed.json ' )) {
159
- $ loader = require $ v .'/autoload.php ' ;
160
- $ reflection = new \ReflectionClass ($ loader );
161
- $ prop = $ reflection ->getProperty ('prefixDirsPsr4 ' );
162
- $ prop ->setAccessible (true );
163
- $ currentValue = $ prop ->getValue ($ loader );
164
- $ currentValue ['Symfony \\Bridge \\PhpUnit \\' ] = [realpath (__DIR__ .'/../.. ' )];
165
- $ prop ->setValue ($ loader , $ currentValue );
166
- }
167
- }
168
- }
169
-
170
155
return [
171
156
'not_from_vendors_file ' => [Deprecation::TYPE_SELF , '' , 'MyClass1 ' , __FILE__ ],
172
157
'nonexistent_file ' => [Deprecation::TYPE_UNDETERMINED , '' , 'MyClass1 ' , 'dummy_vendor_path ' ],
@@ -276,8 +261,32 @@ private static function removeDir($dir)
276
261
rmdir ($ dir );
277
262
}
278
263
264
+ private static function doSetupBeforeClass ()
265
+ {
266
+ foreach (get_declared_classes () as $ class ) {
267
+ if ('C ' === $ class [0 ] && 0 === strpos ($ class , 'ComposerAutoloaderInit ' )) {
268
+ $ r = new \ReflectionClass ($ class );
269
+ $ v = \dirname (\dirname ($ r ->getFileName ()));
270
+ if (file_exists ($ v .'/composer/installed.json ' )) {
271
+ $ loader = require $ v .'/autoload.php ' ;
272
+ $ reflection = new \ReflectionClass ($ loader );
273
+ $ prop = $ reflection ->getProperty ('prefixDirsPsr4 ' );
274
+ $ prop ->setAccessible (true );
275
+ $ currentValue = $ prop ->getValue ($ loader );
276
+ self ::$ prefixDirsPsr4 [] = [$ prop , $ loader , $ currentValue ];
277
+ $ currentValue ['Symfony \\Bridge \\PhpUnit \\' ] = [realpath (__DIR__ .'/../.. ' )];
278
+ $ prop ->setValue ($ loader , $ currentValue );
279
+ }
280
+ }
281
+ }
282
+ }
283
+
279
284
private static function doTearDownAfterClass ()
280
285
{
286
+ foreach (self ::$ prefixDirsPsr4 as [$ prop , $ loader , $ prefixDirsPsr4 ]) {
287
+ $ prop ->setValue ($ loader , $ prefixDirsPsr4 );
288
+ }
289
+
281
290
self ::removeDir (self ::getVendorDir ().'/myfakevendor ' );
282
291
}
283
292
}
0 commit comments