Skip to content

Commit

Permalink
chore: rename driver methods into StarterKitStack format
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbutcher committed Oct 6, 2023
1 parent 6c69741 commit fc9879e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
28 changes: 14 additions & 14 deletions src/Installer/InstallManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
30 changes: 27 additions & 3 deletions tests/Unit/InstallerManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit fc9879e

Please sign in to comment.