mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 01:37:21 +01:00
chore: different refactors
This commit is contained in:
@ -11,8 +11,6 @@ use ParaTest\RunnerInterface;
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use Pest\Plugins\Concerns\HandleArguments;
|
||||
use Pest\Plugins\Parallel\Paratest\WrapperRunner;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
/**
|
||||
@ -22,13 +20,6 @@ final class Laravel implements HandlesArguments
|
||||
{
|
||||
use HandleArguments;
|
||||
|
||||
public function __construct(
|
||||
private readonly OutputInterface $output,
|
||||
private readonly InputInterface $input,
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
public function handleArguments(array $arguments): array
|
||||
{
|
||||
if (! self::isALaravelApplication()) {
|
||||
@ -44,22 +35,22 @@ final class Laravel implements HandlesArguments
|
||||
|
||||
private function setLaravelParallelRunner(): void
|
||||
{
|
||||
if (! method_exists(ParallelRunner::class, 'resolveRunnerUsing')) {
|
||||
$this->output->writeln(' <fg=red>Using parallel with Pest requires Laravel v8.55.0 or higher.</>');
|
||||
exit(Command::FAILURE);
|
||||
}
|
||||
|
||||
ParallelRunner::resolveRunnerUsing(fn (Options $options, OutputInterface $output): RunnerInterface => new WrapperRunner($options, $output));
|
||||
ParallelRunner::resolveRunnerUsing( // @phpstan-ignore-line
|
||||
fn (Options $options, OutputInterface $output): RunnerInterface => new WrapperRunner($options, $output)
|
||||
);
|
||||
}
|
||||
|
||||
private static function isALaravelApplication(): bool
|
||||
{
|
||||
return InstalledVersions::isInstalled('laravel/framework', false)
|
||||
&& ! class_exists(\Orchestra\Testbench\TestCase::class);
|
||||
if (! InstalledVersions::isInstalled('laravel/framework', false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ! class_exists(\Orchestra\Testbench\TestCase::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $arguments
|
||||
* @param array<int, string> $arguments
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function setEnvironmentVariables(array $arguments): array
|
||||
@ -75,17 +66,18 @@ final class Laravel implements HandlesArguments
|
||||
}
|
||||
|
||||
$arguments = $this->popArgument('--recreate-databases', $arguments);
|
||||
|
||||
return $this->popArgument('--drop-databases', $arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<int, string> $arguments
|
||||
* @param array<int, string> $arguments
|
||||
* @return array<int, string>
|
||||
*/
|
||||
private function useLaravelRunner(array $arguments): array
|
||||
{
|
||||
foreach ($arguments as $value) {
|
||||
if (str_starts_with((string)$value, '--runner')) {
|
||||
if (str_starts_with($value, '--runner')) {
|
||||
$arguments = $this->popArgument($value, $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,13 +1,15 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Pest\Plugins\Parallel\Handlers;
|
||||
|
||||
use Pest\Contracts\Plugins\HandlesArguments;
|
||||
use Pest\Plugins\Concerns\HandleArguments;
|
||||
use Pest\Plugins\Parallel\Contracts\HandlesSubprocessArguments;
|
||||
use Pest\Plugins\Parallel\Contracts\HandlersWorkerArguments;
|
||||
use Pest\Plugins\Retry;
|
||||
|
||||
final class Pest implements HandlesArguments, HandlesSubprocessArguments
|
||||
final class Pest implements HandlesArguments, HandlersWorkerArguments
|
||||
{
|
||||
use HandleArguments;
|
||||
|
||||
@ -20,7 +22,7 @@ final class Pest implements HandlesArguments, HandlesSubprocessArguments
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
public function handleSubprocessArguments(array $arguments): array
|
||||
public function handleWorkerArguments(array $arguments): array
|
||||
{
|
||||
$_SERVER['PEST_PARALLEL'] = '1';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user