@@ -33,7 +33,7 @@ public static function setUpBeforeClass()
33
33
}
34
34
35
35
if ($ function [0 ] instanceof ComposerClassLoader) {
36
- $ function [0 ]->add ('Symfony\Component\Debug\Tests\Fixtures ' , dirname (dirname (dirname (dirname (dirname (__DIR__ ))))));
36
+ $ function [0 ]->add ('Symfony_Component_Debug_Tests_Fixtures ' , dirname (dirname (dirname (dirname (dirname (__DIR__ ))))));
37
37
break ;
38
38
}
39
39
}
@@ -42,12 +42,25 @@ public static function setUpBeforeClass()
42
42
/**
43
43
* @dataProvider provideClassNotFoundData
44
44
*/
45
- public function testHandleClassNotFound ($ error , $ translatedMessage )
45
+ public function testHandleClassNotFound ($ error , $ translatedMessage, $ autoloader = null )
46
46
{
47
+ if ($ autoloader ) {
48
+ // Unregister all autoloaders to ensure the custom provided
49
+ // autoloader is the only one to be used during the test run.
50
+ $ autoloaders = spl_autoload_functions ();
51
+ array_map ('spl_autoload_unregister ' , $ autoloaders );
52
+ spl_autoload_register ($ autoloader );
53
+ }
54
+
47
55
$ handler = new ClassNotFoundFatalErrorHandler ();
48
56
49
57
$ exception = $ handler ->handleError ($ error , new FatalErrorException ('' , 0 , $ error ['type ' ], $ error ['file ' ], $ error ['line ' ]));
50
58
59
+ if ($ autoloader ) {
60
+ spl_autoload_unregister ($ autoloader );
61
+ array_map ('spl_autoload_register ' , $ autoloaders );
62
+ }
63
+
51
64
$ this ->assertInstanceof ('Symfony\Component\Debug\Exception\ClassNotFoundException ' , $ exception );
52
65
$ this ->assertSame ($ translatedMessage , $ exception ->getMessage ());
53
66
$ this ->assertSame ($ error ['type ' ], $ exception ->getSeverity ());
@@ -56,33 +69,37 @@ public function testHandleClassNotFound($error, $translatedMessage)
56
69
}
57
70
58
71
/**
59
- * @dataProvider provideLegacyClassNotFoundData
60
72
* @group legacy
61
73
*/
62
- public function testLegacyHandleClassNotFound ($ error , $ translatedMessage , $ autoloader )
74
+ public function testLegacyHandleClassNotFound ()
63
75
{
64
- // Unregister all autoloaders to ensure the custom provided
65
- // autoloader is the only one to be used during the test run.
66
- $ autoloaders = spl_autoload_functions ();
67
- array_map ('spl_autoload_unregister ' , $ autoloaders );
68
- spl_autoload_register ($ autoloader );
69
-
70
- $ handler = new ClassNotFoundFatalErrorHandler ();
71
-
72
- $ exception = $ handler ->handleError ($ error , new FatalErrorException ('' , 0 , $ error ['type ' ], $ error ['file ' ], $ error ['line ' ]));
76
+ $ this ->iniSet ('error_reporting ' , -1 & ~E_USER_DEPRECATED );
73
77
74
- spl_autoload_unregister ($ autoloader );
75
- array_map ('spl_autoload_register ' , $ autoloaders );
78
+ $ prefixes = array ('Symfony\Component\Debug\Exception \\' => realpath (__DIR__ .'/../../Exception ' ));
79
+ $ symfonyUniversalClassLoader = new SymfonyUniversalClassLoader ();
80
+ $ symfonyUniversalClassLoader ->registerPrefixes ($ prefixes );
76
81
77
- $ this ->assertInstanceof ('Symfony\Component\Debug\Exception\ClassNotFoundException ' , $ exception );
78
- $ this ->assertSame ($ translatedMessage , $ exception ->getMessage ());
79
- $ this ->assertSame ($ error ['type ' ], $ exception ->getSeverity ());
80
- $ this ->assertSame ($ error ['file ' ], $ exception ->getFile ());
81
- $ this ->assertSame ($ error ['line ' ], $ exception ->getLine ());
82
+ $ this ->testHandleClassNotFound (
83
+ array (
84
+ 'type ' => 1 ,
85
+ 'line ' => 12 ,
86
+ 'file ' => 'foo.php ' ,
87
+ 'message ' => 'Class \'Foo \\Bar \\UndefinedFunctionException \' not found ' ,
88
+ ),
89
+ "Attempted to load class \"UndefinedFunctionException \" from namespace \"Foo\Bar \". \nDid you forget a \"use \" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException \"? " ,
90
+ array ($ symfonyUniversalClassLoader , 'loadClass ' )
91
+ );
82
92
}
83
93
84
94
public function provideClassNotFoundData ()
85
95
{
96
+ $ prefixes = array ('Symfony\Component\Debug\Exception \\' => realpath (__DIR__ .'/../../Exception ' ));
97
+
98
+ $ symfonyAutoloader = new SymfonyClassLoader ();
99
+ $ symfonyAutoloader ->addPrefixes ($ prefixes );
100
+
101
+ $ debugClassLoader = new DebugClassLoader ($ symfonyAutoloader );
102
+
86
103
return array (
87
104
array (
88
105
array (
@@ -129,26 +146,6 @@ public function provideClassNotFoundData()
129
146
),
130
147
"Attempted to load class \"UndefinedFunctionException \" from namespace \"Foo\Bar \". \nDid you forget a \"use \" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException \"? " ,
131
148
),
132
- );
133
- }
134
-
135
- public function provideLegacyClassNotFoundData ()
136
- {
137
- $ this ->iniSet ('error_reporting ' , -1 & ~E_USER_DEPRECATED );
138
-
139
- $ prefixes = array ('Symfony\Component\Debug\Exception \\' => realpath (__DIR__ .'/../../Exception ' ));
140
-
141
- $ symfonyAutoloader = new SymfonyClassLoader ();
142
- $ symfonyAutoloader ->addPrefixes ($ prefixes );
143
-
144
- if (class_exists ('Symfony\Component\ClassLoader\UniversalClassLoader ' )) {
145
- $ symfonyUniversalClassLoader = new SymfonyUniversalClassLoader ();
146
- $ symfonyUniversalClassLoader ->registerPrefixes ($ prefixes );
147
- } else {
148
- $ symfonyUniversalClassLoader = $ symfonyAutoloader ;
149
- }
150
-
151
- return array (
152
149
array (
153
150
array (
154
151
'type ' => 1 ,
@@ -167,7 +164,7 @@ public function provideLegacyClassNotFoundData()
167
164
'message ' => 'Class \'Foo \\Bar \\UndefinedFunctionException \' not found ' ,
168
165
),
169
166
"Attempted to load class \"UndefinedFunctionException \" from namespace \"Foo\Bar \". \nDid you forget a \"use \" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException \"? " ,
170
- array ($ symfonyUniversalClassLoader , 'loadClass ' ),
167
+ array ($ debugClassLoader , 'loadClass ' ),
171
168
),
172
169
array (
173
170
array (
0 commit comments