|
426 | 426 | ->toContain('Run `npm install` to install dependencies') |
427 | 427 | ->toContain('Package manager: npm'); |
428 | 428 | }); |
| 429 | + |
| 430 | +test('includes wayfinder guidelines with inertia integration when both packages are present', function (): void { |
| 431 | + $packages = new PackageCollection([ |
| 432 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 433 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 434 | + new Package(Packages::INERTIA_REACT, 'inertiajs/inertia-react', '2.1.2'), |
| 435 | + new Package(Packages::INERTIA_LARAVEL, 'inertiajs/inertia-laravel', '2.1.2'), |
| 436 | + ]); |
| 437 | + |
| 438 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 439 | + |
| 440 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(true); |
| 441 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(true); |
| 442 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(false); |
| 443 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false); |
| 444 | + |
| 445 | + $this->roster->shouldReceive('usesVersion') |
| 446 | + ->with(Packages::INERTIA_LARAVEL, '2.1.0', '>=') |
| 447 | + ->andReturn(true); |
| 448 | + $this->roster->shouldReceive('usesVersion') |
| 449 | + ->with(Packages::INERTIA_REACT, '2.1.0', '>=') |
| 450 | + ->andReturn(true); |
| 451 | + $this->roster->shouldReceive('usesVersion') |
| 452 | + ->with(Packages::INERTIA_VUE, '2.1.0', '>=') |
| 453 | + ->andReturn(false); |
| 454 | + $this->roster->shouldReceive('usesVersion') |
| 455 | + ->with(Packages::INERTIA_SVELTE, '2.1.0', '>=') |
| 456 | + ->andReturn(false); |
| 457 | + |
| 458 | + $this->roster->shouldReceive('usesVersion') |
| 459 | + ->with(Packages::INERTIA_LARAVEL, '2.1.2', '>=') |
| 460 | + ->andReturn(true); |
| 461 | + $this->roster->shouldReceive('usesVersion') |
| 462 | + ->with(Packages::INERTIA_REACT, '2.1.2', '>=') |
| 463 | + ->andReturn(true); |
| 464 | + $this->roster->shouldReceive('usesVersion') |
| 465 | + ->with(Packages::INERTIA_VUE, '2.1.2', '>=') |
| 466 | + ->andReturn(false); |
| 467 | + $this->roster->shouldReceive('usesVersion') |
| 468 | + ->with(Packages::INERTIA_SVELTE, '2.1.2', '>=') |
| 469 | + ->andReturn(false); |
| 470 | + |
| 471 | + $guidelines = $this->composer->compose(); |
| 472 | + |
| 473 | + expect($guidelines) |
| 474 | + ->toContain('=== wayfinder/core rules ===') |
| 475 | + ->toContain('Wayfinder + Inertia') |
| 476 | + ->toContain('Wayfinder Form Component (React)') |
| 477 | + ->toContain('<Form {...store.form()}>') |
| 478 | + ->toContain('## Laravel Wayfinder'); |
| 479 | +}); |
| 480 | + |
| 481 | +test('includes wayfinder guidelines without inertia integration when inertia is not present', function (): void { |
| 482 | + $packages = new PackageCollection([ |
| 483 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 484 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 485 | + ]); |
| 486 | + |
| 487 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 488 | + |
| 489 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(false); |
| 490 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(false); |
| 491 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(false); |
| 492 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false); |
| 493 | + |
| 494 | + $this->roster->shouldReceive('usesVersion') |
| 495 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
| 496 | + ->andReturn(false); |
| 497 | + $this->roster->shouldReceive('usesVersion') |
| 498 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
| 499 | + ->andReturn(false); |
| 500 | + $this->roster->shouldReceive('usesVersion') |
| 501 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
| 502 | + ->andReturn(false); |
| 503 | + $this->roster->shouldReceive('usesVersion') |
| 504 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
| 505 | + ->andReturn(false); |
| 506 | + |
| 507 | + $guidelines = $this->composer->compose(); |
| 508 | + |
| 509 | + expect($guidelines) |
| 510 | + ->toContain('=== wayfinder/core rules ===') |
| 511 | + ->toContain('## Laravel Wayfinder') |
| 512 | + ->toContain('import { show } from \'@/actions/') |
| 513 | + ->not->toContain('Wayfinder + Inertia') |
| 514 | + ->not->toContain('Wayfinder Form Component'); |
| 515 | +}); |
| 516 | + |
0 commit comments