Skip to content

Commit adf42f0

Browse files
[2.x] Fixes Laravel 10 --pest installation (#1246)
* Fixes Laravel 10 `--pest` installation * Update tests.yml --------- Co-authored-by: Dries Vints <[email protected]>
1 parent e630605 commit adf42f0

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

.github/workflows/tests.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ jobs:
7979
- name: Install Jetstream
8080
run: |
8181
composer update "laravel/jetstream" --prefer-dist --no-interaction --no-progress -W
82-
php artisan jetstream:install ${{ matrix.stack }} --teams --api --verification
82+
php artisan jetstream:install ${{ matrix.stack }} --teams --api --verification --pest
8383
8484
- name: Install NPM dependencies
8585
run: npm i
@@ -88,7 +88,7 @@ jobs:
8888
run: npm run build
8989

9090
- name: Execute tests
91-
run: vendor/bin/phpunit
91+
run: vendor/bin/pest
9292
env:
9393
DB_CONNECTION: sqlite
9494
DB_DATABASE: ":memory:"

src/Console/InstallCommand.php

+29-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ public function handle()
9595
$stubs = $this->getTestStubsPath();
9696

9797
if ($this->option('pest')) {
98-
if (! $this->requireComposerDevPackages('pestphp/pest:^1.22', 'pestphp/pest-plugin-laravel:^1.4')) {
98+
$this->removeComposerDevPackages(['nunomaduro/collision', 'phpunit/phpunit']);
99+
100+
if (! $this->requireComposerDevPackages(['nunomaduro/collision:^6.4', 'pestphp/pest:^1.22', 'pestphp/pest-plugin-laravel:^1.2'])) {
99101
return 1;
100102
}
101103

@@ -644,6 +646,32 @@ protected function requireComposerPackages($packages)
644646
});
645647
}
646648

649+
/**
650+
* Removes the given Composer Packages as "dev" dependencies.
651+
*
652+
* @param mixed $packages
653+
* @return bool
654+
*/
655+
protected function removeComposerDevPackages($packages)
656+
{
657+
$composer = $this->option('composer');
658+
659+
if ($composer !== 'global') {
660+
$command = [$this->phpBinary(), $composer, 'remove', '--dev'];
661+
}
662+
663+
$command = array_merge(
664+
$command ?? ['composer', 'remove', '--dev'],
665+
is_array($packages) ? $packages : func_get_args()
666+
);
667+
668+
return (new Process($command, base_path(), ['COMPOSER_MEMORY_LIMIT' => '-1']))
669+
->setTimeout(null)
670+
->run(function ($type, $output) {
671+
$this->output->write($output);
672+
}) === 0;
673+
}
674+
647675
/**
648676
* Install the given Composer Packages as "dev" dependencies.
649677
*

0 commit comments

Comments
 (0)