From 1c11b7893fa3e9c592f6e85b2b1b0028ddd55645 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sat, 30 Jan 2021 13:48:51 -0600 Subject: [PATCH] allow trait to be moved --- src/Illuminate/Testing/ParallelRunner.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Illuminate/Testing/ParallelRunner.php b/src/Illuminate/Testing/ParallelRunner.php index e26528703bbe..b2bcdf1b7447 100644 --- a/src/Illuminate/Testing/ParallelRunner.php +++ b/src/Illuminate/Testing/ParallelRunner.php @@ -2,11 +2,13 @@ namespace Illuminate\Testing; +use Illuminate\Contracts\Console\Kernel; use Illuminate\Support\Facades\ParallelTesting; use ParaTest\Runners\PHPUnit\Options; use ParaTest\Runners\PHPUnit\RunnerInterface; use ParaTest\Runners\PHPUnit\WrapperRunner; use PHPUnit\TextUI\XmlConfiguration\PhpHandler; +use RuntimeException; use Symfony\Component\Console\Output\ConsoleOutput; use Symfony\Component\Console\Output\OutputInterface; @@ -128,13 +130,23 @@ protected function forEachProcess($callback) protected function createApplication() { $applicationResolver = static::$applicationResolver ?: function () { - $applicationCreator = new class { - use \Tests\CreatesApplication; - }; + if (trait_exists(\Tests\CreatesApplication::class)) { + $applicationCreator = new class { + use \Tests\CreatesApplication; + }; - return $applicationCreator->createApplication(); + return $applicationCreator->createApplication(); + } elseif (file_exists(getcwd().'/bootstrap/app.php')) { + $app = require getcwd().'/bootstrap/app.php'; + + $app->make(Kernel::class)->bootstrap(); + + return $app; + } + + throw new RuntimeException('Parallel Runner unable to resolve application.'); }; return call_user_func($applicationResolver); } -} +} \ No newline at end of file