|
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); |
|
443 | 442 | $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false); |
444 | 443 |
|
445 | 444 | $this->roster->shouldReceive('usesVersion') |
446 | | - ->with(Packages::INERTIA_LARAVEL, '2.1.0', '>=') |
| 445 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
447 | 446 | ->andReturn(true); |
448 | 447 | $this->roster->shouldReceive('usesVersion') |
449 | | - ->with(Packages::INERTIA_REACT, '2.1.0', '>=') |
| 448 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
450 | 449 | ->andReturn(true); |
451 | 450 | $this->roster->shouldReceive('usesVersion') |
452 | | - ->with(Packages::INERTIA_VUE, '2.1.0', '>=') |
| 451 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
453 | 452 | ->andReturn(false); |
454 | 453 | $this->roster->shouldReceive('usesVersion') |
455 | | - ->with(Packages::INERTIA_SVELTE, '2.1.0', '>=') |
| 454 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
456 | 455 | ->andReturn(false); |
457 | 456 |
|
| 457 | + $guidelines = $this->composer->compose(); |
| 458 | + |
| 459 | + expect($guidelines) |
| 460 | + ->toContain('=== wayfinder/core rules ===') |
| 461 | + ->toContain('Wayfinder + Inertia') |
| 462 | + ->toContain('Wayfinder Form Component (React)') |
| 463 | + ->toContain('<Form {...store.form()}>') |
| 464 | + ->toContain('## Laravel Wayfinder'); |
| 465 | +}); |
| 466 | + |
| 467 | +test('includes wayfinder guidelines with inertia vue integration', function (): void { |
| 468 | + $packages = new PackageCollection([ |
| 469 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 470 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 471 | + new Package(Packages::INERTIA_VUE, 'inertiajs/inertia-vue', '2.1.2'), |
| 472 | + new Package(Packages::INERTIA_LARAVEL, 'inertiajs/inertia-laravel', '2.1.2'), |
| 473 | + ]); |
| 474 | + |
| 475 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 476 | + |
| 477 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(true); |
| 478 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(false); |
| 479 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(true); |
| 480 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false); |
| 481 | + |
458 | 482 | $this->roster->shouldReceive('usesVersion') |
459 | | - ->with(Packages::INERTIA_LARAVEL, '2.1.2', '>=') |
| 483 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
460 | 484 | ->andReturn(true); |
461 | 485 | $this->roster->shouldReceive('usesVersion') |
462 | | - ->with(Packages::INERTIA_REACT, '2.1.2', '>=') |
| 486 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
| 487 | + ->andReturn(false); |
| 488 | + $this->roster->shouldReceive('usesVersion') |
| 489 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
463 | 490 | ->andReturn(true); |
464 | 491 | $this->roster->shouldReceive('usesVersion') |
465 | | - ->with(Packages::INERTIA_VUE, '2.1.2', '>=') |
| 492 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
| 493 | + ->andReturn(false); |
| 494 | + |
| 495 | + $guidelines = $this->composer->compose(); |
| 496 | + |
| 497 | + expect($guidelines) |
| 498 | + ->toContain('=== wayfinder/core rules ===') |
| 499 | + ->toContain('Wayfinder + Inertia') |
| 500 | + ->toContain('Wayfinder Form Component (Vue)') |
| 501 | + ->toContain('<Form v-bind="store.form()">') |
| 502 | + ->toContain('## Laravel Wayfinder'); |
| 503 | +}); |
| 504 | + |
| 505 | +test('includes wayfinder guidelines with inertia svelte integration', function (): void { |
| 506 | + $packages = new PackageCollection([ |
| 507 | + new Package(Packages::LARAVEL, 'laravel/framework', '11.0.0'), |
| 508 | + new Package(Packages::WAYFINDER, 'laravel/wayfinder', '1.0.0'), |
| 509 | + new Package(Packages::INERTIA_SVELTE, 'inertiajs/inertia-svelte', '2.1.2'), |
| 510 | + new Package(Packages::INERTIA_LARAVEL, 'inertiajs/inertia-laravel', '2.1.2'), |
| 511 | + ]); |
| 512 | + |
| 513 | + $this->roster->shouldReceive('packages')->andReturn($packages); |
| 514 | + |
| 515 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_LARAVEL)->andReturn(true); |
| 516 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_REACT)->andReturn(false); |
| 517 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_VUE)->andReturn(false); |
| 518 | + $this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(true); |
| 519 | + |
| 520 | + $this->roster->shouldReceive('usesVersion') |
| 521 | + ->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=') |
| 522 | + ->andReturn(true); |
| 523 | + $this->roster->shouldReceive('usesVersion') |
| 524 | + ->with(Packages::INERTIA_REACT, Mockery::any(), '>=') |
466 | 525 | ->andReturn(false); |
467 | 526 | $this->roster->shouldReceive('usesVersion') |
468 | | - ->with(Packages::INERTIA_SVELTE, '2.1.2', '>=') |
| 527 | + ->with(Packages::INERTIA_VUE, Mockery::any(), '>=') |
469 | 528 | ->andReturn(false); |
| 529 | + $this->roster->shouldReceive('usesVersion') |
| 530 | + ->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=') |
| 531 | + ->andReturn(true); |
470 | 532 |
|
471 | 533 | $guidelines = $this->composer->compose(); |
472 | 534 |
|
473 | 535 | expect($guidelines) |
474 | 536 | ->toContain('=== wayfinder/core rules ===') |
475 | 537 | ->toContain('Wayfinder + Inertia') |
476 | | - ->toContain('Wayfinder Form Component (React)') |
| 538 | + ->toContain('Wayfinder Form Component (Svelte)') |
477 | 539 | ->toContain('<Form {...store.form()}>') |
478 | 540 | ->toContain('## Laravel Wayfinder'); |
479 | 541 | }); |
|
0 commit comments