|
23 | 23 | $this->herd = Mockery::mock(Herd::class); |
24 | 24 | $this->herd->shouldReceive('isInstalled')->andReturn(false)->byDefault(); |
25 | 25 |
|
26 | | - // Bind the mock to the service container so it's used everywhere |
27 | 26 | $this->app->instance(Roster::class, $this->roster); |
28 | 27 |
|
29 | 28 | $this->composer = new GuidelineComposer($this->roster, $this->herd); |
|
37 | 36 | ]); |
38 | 37 |
|
39 | 38 | $this->roster->shouldReceive('packages')->andReturn($packages); |
40 | | - // Mock all Inertia package version checks |
41 | 39 | $this->roster->shouldReceive('usesVersion') |
42 | 40 | ->with(Packages::INERTIA_LARAVEL, '2.1.0', '>=') |
43 | 41 | ->andReturn($shouldIncludeForm); |
|
432 | 430 | ->not->toContain('volt-anonymous-fragment') |
433 | 431 | ->not->toContain('@livewire'); |
434 | 432 | }); |
| 433 | + |
| 434 | +test('includes wayfinder guidelines with inertia integration when both packages are present', function (): void { |
| 435 | + $packages = new PackageCollection([ |
| 436 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 437 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 438 | + new Package(Packages::INERTIA_REACT, 'inertiajs/inertia-react', '2.1.2'), |
| 439 | + new Package(Packages::INERTIA_LARAVEL, 'inertiajs/inertia-laravel', '2.1.2'), |
| 440 | + ]); |
| 441 | + |
| 442 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 443 | + |
| 444 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(true); |
| 445 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(true); |
| 446 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(false); |
| 447 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false); |
| 448 | + |
| 449 | + $this->roster->shouldReceive('usesVersion') |
| 450 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
| 451 | + ->andReturn(true); |
| 452 | + $this->roster->shouldReceive('usesVersion') |
| 453 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
| 454 | + ->andReturn(true); |
| 455 | + $this->roster->shouldReceive('usesVersion') |
| 456 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
| 457 | + ->andReturn(false); |
| 458 | + $this->roster->shouldReceive('usesVersion') |
| 459 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
| 460 | + ->andReturn(false); |
| 461 | + |
| 462 | + $guidelines = $this->composer->compose(); |
| 463 | + |
| 464 | + expect($guidelines) |
| 465 | + ->toContain('=== wayfinder/core rules ===') |
| 466 | + ->toContain('Wayfinder + Inertia') |
| 467 | + ->toContain('Wayfinder Form Component (React)') |
| 468 | + ->toContain('<Form {...store.form()}>') |
| 469 | + ->toContain('## Laravel Wayfinder') |
| 470 | + ->not->toContain('Wayfinder Form Component (Vue)') |
| 471 | + ->not->toContain('Wayfinder Form Component (Svelte)') |
| 472 | + ->not->toContain('<Form v-bind="store.form()">'); |
| 473 | +}); |
| 474 | + |
| 475 | +test('includes wayfinder guidelines with inertia vue integration', function (): void { |
| 476 | + $packages = new PackageCollection([ |
| 477 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 478 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 479 | + new Package(Packages::INERTIA_VUE, 'inertiajs/inertia-vue', '2.1.2'), |
| 480 | + new Package(Packages::INERTIA_LARAVEL, 'inertiajs/inertia-laravel', '2.1.2'), |
| 481 | + ]); |
| 482 | + |
| 483 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 484 | + |
| 485 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(true); |
| 486 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(false); |
| 487 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(true); |
| 488 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false); |
| 489 | + |
| 490 | + $this->roster->shouldReceive('usesVersion') |
| 491 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
| 492 | + ->andReturn(true); |
| 493 | + $this->roster->shouldReceive('usesVersion') |
| 494 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
| 495 | + ->andReturn(false); |
| 496 | + $this->roster->shouldReceive('usesVersion') |
| 497 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
| 498 | + ->andReturn(true); |
| 499 | + $this->roster->shouldReceive('usesVersion') |
| 500 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
| 501 | + ->andReturn(false); |
| 502 | + |
| 503 | + $guidelines = $this->composer->compose(); |
| 504 | + |
| 505 | + expect($guidelines) |
| 506 | + ->toContain('=== wayfinder/core rules ===') |
| 507 | + ->toContain('Wayfinder + Inertia') |
| 508 | + ->toContain('Wayfinder Form Component (Vue)') |
| 509 | + ->toContain('<Form v-bind="store.form()">') |
| 510 | + ->toContain('## Laravel Wayfinder') |
| 511 | + ->not->toContain('Wayfinder Form Component (React)') |
| 512 | + ->not->toContain('Wayfinder Form Component (Svelte)'); |
| 513 | +}); |
| 514 | + |
| 515 | +test('includes wayfinder guidelines with inertia svelte integration', function (): void { |
| 516 | + $packages = new PackageCollection([ |
| 517 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 518 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 519 | + new Package(Packages::INERTIA_SVELTE, 'inertiajs/inertia-svelte', '2.1.2'), |
| 520 | + new Package(Packages::INERTIA_LARAVEL, 'inertiajs/inertia-laravel', '2.1.2'), |
| 521 | + ]); |
| 522 | + |
| 523 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 524 | + |
| 525 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(true); |
| 526 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(false); |
| 527 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(false); |
| 528 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(true); |
| 529 | + |
| 530 | + $this->roster->shouldReceive('usesVersion') |
| 531 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
| 532 | + ->andReturn(true); |
| 533 | + $this->roster->shouldReceive('usesVersion') |
| 534 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
| 535 | + ->andReturn(false); |
| 536 | + $this->roster->shouldReceive('usesVersion') |
| 537 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
| 538 | + ->andReturn(false); |
| 539 | + $this->roster->shouldReceive('usesVersion') |
| 540 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
| 541 | + ->andReturn(true); |
| 542 | + |
| 543 | + $guidelines = $this->composer->compose(); |
| 544 | + |
| 545 | + expect($guidelines) |
| 546 | + ->toContain('=== wayfinder/core rules ===') |
| 547 | + ->toContain('Wayfinder + Inertia') |
| 548 | + ->toContain('Wayfinder Form Component (Svelte)') |
| 549 | + ->toContain('<Form {...store.form()}>') |
| 550 | + ->toContain('## Laravel Wayfinder') |
| 551 | + ->not->toContain('Wayfinder Form Component (React)') |
| 552 | + ->not->toContain('Wayfinder Form Component (Vue)') |
| 553 | + ->not->toContain('<Form v-bind="store.form()">'); |
| 554 | +}); |
| 555 | + |
| 556 | +test('includes wayfinder guidelines without inertia integration when inertia is not present', function (): void { |
| 557 | + $packages = new PackageCollection([ |
| 558 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 559 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 560 | + ]); |
| 561 | + |
| 562 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 563 | + |
| 564 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(false); |
| 565 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(false); |
| 566 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(false); |
| 567 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false); |
| 568 | + |
| 569 | + $this->roster->shouldReceive('usesVersion') |
| 570 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
| 571 | + ->andReturn(false); |
| 572 | + $this->roster->shouldReceive('usesVersion') |
| 573 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
| 574 | + ->andReturn(false); |
| 575 | + $this->roster->shouldReceive('usesVersion') |
| 576 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
| 577 | + ->andReturn(false); |
| 578 | + $this->roster->shouldReceive('usesVersion') |
| 579 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
| 580 | + ->andReturn(false); |
| 581 | + |
| 582 | + $guidelines = $this->composer->compose(); |
| 583 | + |
| 584 | + expect($guidelines) |
| 585 | + ->toContain('=== wayfinder/core rules ===') |
| 586 | + ->toContain('## Laravel Wayfinder') |
| 587 | + ->toContain('import { show } from \'@/actions/') |
| 588 | + ->not->toContain('Wayfinder + Inertia') |
| 589 | + ->not->toContain('Wayfinder Form Component'); |
| 590 | +}); |
0 commit comments