@@ -33,7 +33,7 @@ public static function setUpBeforeClass()
3333 }
3434
3535 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__ ))))));
3737 break ;
3838 }
3939 }
@@ -42,12 +42,25 @@ public static function setUpBeforeClass()
4242 /**
4343 * @dataProvider provideClassNotFoundData
4444 */
45- public function testHandleClassNotFound ($ error , $ translatedMessage )
45+ public function testHandleClassNotFound ($ error , $ translatedMessage, $ autoloader = null )
4646 {
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+
4755 $ handler = new ClassNotFoundFatalErrorHandler ();
4856
4957 $ exception = $ handler ->handleError ($ error , new FatalErrorException ('' , 0 , $ error ['type ' ], $ error ['file ' ], $ error ['line ' ]));
5058
59+ if ($ autoloader ) {
60+ spl_autoload_unregister ($ autoloader );
61+ array_map ('spl_autoload_register ' , $ autoloaders );
62+ }
63+
5164 $ this ->assertInstanceof ('Symfony\Component\Debug\Exception\ClassNotFoundException ' , $ exception );
5265 $ this ->assertSame ($ translatedMessage , $ exception ->getMessage ());
5366 $ this ->assertSame ($ error ['type ' ], $ exception ->getSeverity ());
@@ -56,33 +69,37 @@ public function testHandleClassNotFound($error, $translatedMessage)
5669 }
5770
5871 /**
59- * @dataProvider provideLegacyClassNotFoundData
6072 * @group legacy
6173 */
62- public function testLegacyHandleClassNotFound ($ error , $ translatedMessage , $ autoloader )
74+ public function testLegacyHandleClassNotFound ()
6375 {
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 );
7377
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 );
7681
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+ );
8292 }
8393
8494 public function provideClassNotFoundData ()
8595 {
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+
86103 return array (
87104 array (
88105 array (
@@ -129,26 +146,6 @@ public function provideClassNotFoundData()
129146 ),
130147 "Attempted to load class \"UndefinedFunctionException \" from namespace \"Foo\Bar \". \nDid you forget a \"use \" statement for \"Symfony\Component\Debug\Exception\UndefinedFunctionException \"? " ,
131148 ),
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 (
152149 array (
153150 array (
154151 'type ' => 1 ,
@@ -167,7 +164,7 @@ public function provideLegacyClassNotFoundData()
167164 'message ' => 'Class \'Foo \\Bar \\UndefinedFunctionException \' not found ' ,
168165 ),
169166 "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 ' ),
171168 ),
172169 array (
173170 array (
0 commit comments