Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Improves installation of Pest #311

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 22 additions & 40 deletions src/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,28 +594,30 @@ protected function validateStackOption(InputInterface $input)
*/
protected function installPest(string $directory, InputInterface $input, OutputInterface $output)
{
if ($this->removeComposerPackages(['phpunit/phpunit', '--no-update'], $output, true)
&& $this->requireComposerPackages(['pestphp/pest:^2.0', 'pestphp/pest-plugin-laravel:^2.0'], $output, true)) {
$commands = array_filter([
$this->phpBinary().' ./vendor/bin/pest --init',
]);

$this->runCommands($commands, $input, $output, workingPath: $directory, env: [
'PEST_NO_SUPPORT' => 'true',
]);

$this->replaceFile(
'pest/Feature.php',
$directory.'/tests/Feature/ExampleTest.php',
);
$composerBinary = $this->findComposer();

$this->replaceFile(
'pest/Unit.php',
$directory.'/tests/Unit/ExampleTest.php',
);
$commands = [
$composerBinary.' remove phpunit/phpunit --dev --no-update',
$composerBinary.' require pestphp/pest:^2.0 pestphp/pest-plugin-laravel:^2.0 --no-update --dev',
$composerBinary.' update',
$this->phpBinary().' ./vendor/bin/pest --init',
];

$this->commitChanges('Install Pest', $directory, $input, $output);
}
$this->runCommands($commands, $input, $output, workingPath: $directory, env: [
'PEST_NO_SUPPORT' => 'true',
]);

$this->replaceFile(
'pest/Feature.php',
$directory.'/tests/Feature/ExampleTest.php',
);

$this->replaceFile(
'pest/Unit.php',
$directory.'/tests/Unit/ExampleTest.php',
);

$this->commitChanges('Install Pest', $directory, $input, $output);
}

/**
Expand Down Expand Up @@ -769,26 +771,6 @@ protected function phpBinary()
: 'php';
}

/**
* Install the given Composer Packages into the application.
*
* @return bool
*/
protected function requireComposerPackages(array $packages, OutputInterface $output, bool $asDev = false)
{
return $this->composer->requirePackages($packages, $asDev, $output);
}

/**
* Remove the given Composer Packages from the application.
*
* @return bool
*/
protected function removeComposerPackages(array $packages, OutputInterface $output, bool $asDev = false)
{
return $this->composer->removePackages($packages, $asDev, $output);
}

/**
* Run the given commands.
*
Expand Down
Loading