Skip to content

Commit 79dec7c

Browse files
alefcasteloDavertMik
authored andcommitted
Bug fix with multiple kernels (#5022)
* Bug fix with multiple kernels It's not possible to set a Kernel different of the AppKernel, and I have two kernels an Admin and an Api, and I need use ApiKernel to run tests This commit makes a checking if kernel defined exists in the path. Because the previous version he gets the first kernel in my case it gets AdminKernel and always returns Kernel not found * Remove 1 space after closing parenthesis
1 parent 2ec9ff6 commit 79dec7c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Codeception/Module/Symfony.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -286,21 +286,23 @@ protected function getKernelClass()
286286
. "Specify directory where file with Kernel class for your application is located with `app_path` parameter."
287287
);
288288
}
289-
$file = current($results);
290289

291290
if (file_exists(codecept_root_dir() . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php')) {
292291
// ensure autoloader from this dir is loaded
293292
require_once codecept_root_dir() . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
294293
}
295294

296-
require_once $file;
295+
$filesRealPath = array_map(function ($file) {
296+
require_once $file;
297+
return $file->getRealPath();
298+
}, $results);
297299

298300
$possibleKernelClasses = $this->getPossibleKernelClasses();
299301

300302
foreach ($possibleKernelClasses as $class) {
301303
if (class_exists($class)) {
302304
$refClass = new \ReflectionClass($class);
303-
if ($refClass->getFileName() === $file->getRealpath()) {
305+
if ($file = array_search($refClass->getFileName(), $filesRealPath)) {
304306
return $class;
305307
}
306308
}

0 commit comments

Comments
 (0)