Skip to content

Commit ecb4647

Browse files
committed
Update tests
Signed-off-by: Pushpak Chhajed <[email protected]>
1 parent 67fded9 commit ecb4647

File tree

1 file changed

+72
-10
lines changed

1 file changed

+72
-10
lines changed

tests/Feature/Install/GuidelineComposerTest.php

Lines changed: 72 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
$this->herd = Mockery::mock(Herd::class);
2424
$this->herd->shouldReceive('isInstalled')->andReturn(false)->byDefault();
2525

26-
// Bind the mock to the service container so it's used everywhere
2726
$this->app->instance(Roster::class, $this->roster);
2827

2928
$this->composer = new GuidelineComposer($this->roster, $this->herd);
@@ -443,37 +442,100 @@
443442
$this->roster->shouldReceive('uses')->with(Packages::INERTIA_SVELTE)->andReturn(false);
444443

445444
$this->roster->shouldReceive('usesVersion')
446-
->with(Packages::INERTIA_LARAVEL, '2.1.0', '>=')
445+
->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=')
447446
->andReturn(true);
448447
$this->roster->shouldReceive('usesVersion')
449-
->with(Packages::INERTIA_REACT, '2.1.0', '>=')
448+
->with(Packages::INERTIA_REACT, Mockery::any(), '>=')
450449
->andReturn(true);
451450
$this->roster->shouldReceive('usesVersion')
452-
->with(Packages::INERTIA_VUE, '2.1.0', '>=')
451+
->with(Packages::INERTIA_VUE, Mockery::any(), '>=')
453452
->andReturn(false);
454453
$this->roster->shouldReceive('usesVersion')
455-
->with(Packages::INERTIA_SVELTE, '2.1.0', '>=')
454+
->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=')
456455
->andReturn(false);
457456

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+
458482
$this->roster->shouldReceive('usesVersion')
459-
->with(Packages::INERTIA_LARAVEL, '2.1.2', '>=')
483+
->with(Packages::INERTIA_LARAVEL, Mockery::any(), '>=')
460484
->andReturn(true);
461485
$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(), '>=')
463490
->andReturn(true);
464491
$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(), '>=')
466525
->andReturn(false);
467526
$this->roster->shouldReceive('usesVersion')
468-
->with(Packages::INERTIA_SVELTE, '2.1.2', '>=')
527+
->with(Packages::INERTIA_VUE, Mockery::any(), '>=')
469528
->andReturn(false);
529+
$this->roster->shouldReceive('usesVersion')
530+
->with(Packages::INERTIA_SVELTE, Mockery::any(), '>=')
531+
->andReturn(true);
470532

471533
$guidelines = $this->composer->compose();
472534

473535
expect($guidelines)
474536
->toContain('=== wayfinder/core rules ===')
475537
->toContain('Wayfinder + Inertia')
476-
->toContain('Wayfinder Form Component (React)')
538+
->toContain('Wayfinder Form Component (Svelte)')
477539
->toContain('<Form {...store.form()}>')
478540
->toContain('## Laravel Wayfinder');
479541
});

0 commit comments

Comments
 (0)