|
5 | 5 | use Laravel\Boost\Install\GuidelineComposer; |
6 | 6 | use Laravel\Boost\Install\GuidelineConfig; |
7 | 7 | use Laravel\Boost\Install\Herd; |
| 8 | +use Laravel\Roster\Enums\NodePackageManager; |
8 | 9 | use Laravel\Roster\Enums\Packages; |
9 | 10 | use Laravel\Roster\Package; |
10 | 11 | use Laravel\Roster\PackageCollection; |
11 | 12 | use Laravel\Roster\Roster; |
12 | 13 |
|
13 | 14 | beforeEach(function (): void { |
14 | 15 | $this->roster = Mockery::mock(Roster::class); |
| 16 | + $this->nodePackageManager = NodePackageManager::NPM; |
| 17 | + $this->roster->shouldReceive('nodePackageManager')->andReturnUsing( |
| 18 | + fn (): NodePackageManager => $this->nodePackageManager |
| 19 | + ); |
| 20 | + |
15 | 21 | $this->herd = Mockery::mock(Herd::class); |
16 | 22 | $this->herd->shouldReceive('isInstalled')->andReturn(false)->byDefault(); |
17 | 23 |
|
|
357 | 363 | ->toContain('=== phpunit/core rules ===') |
358 | 364 | ->not->toContain('=== pest/core rules ==='); |
359 | 365 | }); |
| 366 | + |
| 367 | +test('includes correct package manager commands in guidelines based on lockfile', function (NodePackageManager $packageManager, string $expectedCommand): void { |
| 368 | + $packages = new PackageCollection([ |
| 369 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 370 | + ]); |
| 371 | + $this->nodePackageManager = $packageManager; |
| 372 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 373 | + |
| 374 | + $guidelines = $this->composer->compose(); |
| 375 | + |
| 376 | + expect($guidelines) |
| 377 | + ->toContain("{$expectedCommand} run build") |
| 378 | + ->toContain("{$expectedCommand} run dev"); |
| 379 | +})->with([ |
| 380 | + 'npm' => [NodePackageManager::NPM, 'npm'], |
| 381 | + 'pnpm' => [NodePackageManager::PNPM, 'pnpm'], |
| 382 | + 'yarn' => [NodePackageManager::YARN, 'yarn'], |
| 383 | + 'bun' => [NodePackageManager::BUN, 'bun'], |
| 384 | +]); |
0 commit comments