From fc9879e87c728b7c57a59a30ff9d79c1181e279d Mon Sep 17 00:00:00 2001 From: Joel Butcher Date: Fri, 6 Oct 2023 19:35:34 +0100 Subject: [PATCH] chore: rename driver methods into StarterKitStack format --- src/Console/InstallCommand.php | 2 +- src/Installer/InstallManager.php | 28 +++++++++++++-------------- tests/Unit/InstallerManagerTest.php | 30 ++++++++++++++++++++++++++--- 3 files changed, 42 insertions(+), 18 deletions(-) diff --git a/src/Console/InstallCommand.php b/src/Console/InstallCommand.php index 737cb60b..348ca2a7 100644 --- a/src/Console/InstallCommand.php +++ b/src/Console/InstallCommand.php @@ -63,7 +63,7 @@ public function handle(InstallManager $installManager): ?int $this->getStarterKit() === InstallStarterKit::Filament => 'filament', $this->getStarterKit() === InstallStarterKit::Breeze && $this->getStack() === BreezeInstallStack::Livewire => 'livewire-breeze', - default => $this->getStack()->value.'-'.$this->getStarterKit()->value, + default => $this->getStarterKit()->value.'-'.$this->getStack()->value, })->install( $this->option('composer'), ...collect($this->options()) diff --git a/src/Installer/InstallManager.php b/src/Installer/InstallManager.php index 5fc5f5ce..7943d330 100644 --- a/src/Installer/InstallManager.php +++ b/src/Installer/InstallManager.php @@ -22,38 +22,38 @@ public function getDefaultDriver(): void } - public function createInertiaJetstreamDriver(): InertiaDriver + public function createBreezeBladeDriver(): BladeDriver { - return $this->container->make(InertiaDriver::class); + return $this->container->make(BladeDriver::class); } - public function createLivewireJetstreamDriver(): JetstreamLivewireDriver + public function createBreezeLivewireDriver(): BreezeLivewireDriver { - return $this->container->make(JetstreamLivewireDriver::class); + return $this->container->make(BreezeLivewireDriver::class); } - public function createFilamentDriver(): FilamentDriver + public function createBreezeReactDriver(): ReactInertiaDriver { - return $this->container->make(FilamentDriver::class); + return $this->container->make(ReactInertiaDriver::class); } - public function createBladeBreezeDriver(): BladeDriver + public function createBreezeVueDriver(): VueInertiaDriver { - return $this->container->make(BladeDriver::class); + return $this->container->make(VueInertiaDriver::class); } - public function createLivewireBreezeDriver(): BreezeLivewireDriver + public function createJetstreamInertiaDriver(): InertiaDriver { - return $this->container->make(BreezeLivewireDriver::class); + return $this->container->make(InertiaDriver::class); } - public function createReactBreezeDriver(): ReactInertiaDriver + public function createJetstreamLivewireDriver(): JetstreamLivewireDriver { - return $this->container->make(ReactInertiaDriver::class); + return $this->container->make(JetstreamLivewireDriver::class); } - public function createVueBreezeDriver(): VueInertiaDriver + public function createFilamentDriver(): FilamentDriver { - return $this->container->make(VueInertiaDriver::class); + return $this->container->make(FilamentDriver::class); } } diff --git a/tests/Unit/InstallerManagerTest.php b/tests/Unit/InstallerManagerTest.php index 34b70831..81a01c05 100644 --- a/tests/Unit/InstallerManagerTest.php +++ b/tests/Unit/InstallerManagerTest.php @@ -3,25 +3,49 @@ namespace JoelButcher\Socialstream\Tests\Unit; use JoelButcher\Socialstream\Installer\Drivers\Breeze\BladeDriver; +use JoelButcher\Socialstream\Installer\Drivers\Breeze\LivewireDriver as BreezeLivewireDriver; +use JoelButcher\Socialstream\Installer\Drivers\Breeze\ReactInertiaDriver; +use JoelButcher\Socialstream\Installer\Drivers\Breeze\VueInertiaDriver; +use JoelButcher\Socialstream\Installer\Drivers\Filament\FilamentDriver; use JoelButcher\Socialstream\Installer\Drivers\Jetstream\InertiaDriver; use JoelButcher\Socialstream\Installer\Drivers\Jetstream\LivewireDriver; use JoelButcher\Socialstream\Installer\InstallManager; it('resolves the inertia driver for Laravel Jetstream', function () { - expect(app(InstallManager::class)->driver('inertia-jetstream')) + expect(app(InstallManager::class)->driver('jetstream-inertia')) ->toBeInstanceOf(InertiaDriver::class); }); it('resolves the livewire driver for Laravel Jetstream', function () { - expect(app(InstallManager::class)->driver('livewire-jetstream')) + expect(app(InstallManager::class)->driver('jetstream-livewire')) ->toBeInstanceOf(LivewireDriver::class); }); it('resolves the blade driver for Laravel Breeze', function () { - expect(app(InstallManager::class)->driver('blade-breeze')) + expect(app(InstallManager::class)->driver('breeze-blade')) ->toBeInstanceOf(BladeDriver::class); }); +it('resolves the livewire driver for Laravel Breeze', function () { + expect(app(InstallManager::class)->driver('breeze-livewire')) + ->toBeInstanceOf(BreezeLivewireDriver::class); +}); + +it('resolves the react driver for Laravel Breeze', function () { + expect(app(InstallManager::class)->driver('breeze-react')) + ->toBeInstanceOf(ReactInertiaDriver::class); +}); + +it('resolves the vue driver for Laravel Breeze', function () { + expect(app(InstallManager::class)->driver('breeze-vue')) + ->toBeInstanceOf(VueInertiaDriver::class); +}); + +it('resolves the driver for Filament', function () { + expect(app(InstallManager::class)->driver('filament')) + ->toBeInstanceOf(FilamentDriver::class); +}); + it('throws if no provider is given', function () { expect(fn () => app(InstallManager::class)->driver()) ->toThrow(\InvalidArgumentException::class, sprintf('Unable to resolve NULL driver for [%s].', InstallManager::class));