File tree Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Expand file tree Collapse file tree 1 file changed +21
-5
lines changed Original file line number Diff line number Diff line change 99use Codeception \Lib \Interfaces \PartedModule ;
1010use Symfony \Component \Finder \Finder ;
1111use Symfony \Component \DependencyInjection \ContainerInterface ;
12+ use Symfony \Component \Finder \SplFileInfo ;
1213use Symfony \Component \VarDumper \Cloner \Data ;
1314
1415/**
@@ -257,17 +258,32 @@ protected function getKernelClass()
257258 if (!count ($ results )) {
258259 throw new ModuleRequireException (
259260 __CLASS__ ,
260- "AppKernel was not found at $ path. "
261- . "Specify directory where Kernel class for your application is located with `app_path` parameter. "
261+ "File with Kernel class was not found at $ path. "
262+ . "Specify directory where file with Kernel class for your application is located with `app_path` parameter. "
262263 );
263264 }
264-
265265 $ file = current ($ results );
266- $ class = $ file ->getBasename ('.php ' );
267266
268267 require_once $ file ;
269268
270- return $ class ;
269+ $ possibleKernelClasses = [
270+ 'AppKernel ' , // Symfony Standard
271+ 'App\Kernel ' , // Symfony Flex
272+ ];
273+ foreach ($ possibleKernelClasses as $ class ) {
274+ if (class_exists ($ class )) {
275+ $ refClass = new \ReflectionClass ($ class );
276+ if ($ refClass ->getFileName () === $ file ->getRealpath ()) {
277+ return $ class ;
278+ }
279+ }
280+ }
281+
282+ throw new ModuleRequireException (
283+ __CLASS__ ,
284+ "Kernel class was not found in $ file. "
285+ . "Specify directory where file with Kernel class for your application is located with `app_path` parameter. "
286+ );
271287 }
272288
273289 /**
You can’t perform that action at this time.
0 commit comments