Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom stub file to be used for board. #58

Merged
merged 3 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Commands/MakeKanbanBoardCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class MakeKanbanBoardCommand extends GeneratorCommand

protected function getStub()
{
return __DIR__ . '/../../stubs/board.stub';
return file_exists($customPath = $this->laravel->basePath('/stubs/filament-kanban/board.stub'))
? $customPath
: __DIR__.'/../../stubs/board.stub';
}

protected function getDefaultNamespace($rootNamespace)
{
return $rootNamespace . '\Filament\Pages';
return $rootNamespace.'\Filament\Pages';
}
}
17 changes: 17 additions & 0 deletions tests/Tests/KanbanBoardTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

use Illuminate\Support\Facades\File;
use Mokhosh\FilamentKanban\Tests\Enums\TaskStatus;
use Mokhosh\FilamentKanban\Tests\Models\Task;
use Mokhosh\FilamentKanban\Tests\Pages\TestBoard;
Expand All @@ -9,6 +10,7 @@
use function Pest\Livewire\livewire;

it('can make kanban board from the stub', function () {
File::delete($this->app->basePath('app/Filament/Pages/TestBoard.php'));
$pagesPath = $this->app->basePath('app/Filament/Pages');

$this->artisan('make:kanban TestBoard')->assertExitCode(0);
Expand All @@ -18,6 +20,21 @@
->toContainAsFile('class TestBoard extends KanbanBoard');
});

it('can make kanban board from custom stub', function () {
File::delete($this->app->basePath('app/Filament/Pages/TestBoard.php'));
File::delete($this->app->basePath('stubs/filament-kanban/board.stub'));
File::ensureDirectoryExists($this->app->basePath('/stubs/filament-kanban/'));
File::put($this->app->basePath('/stubs/filament-kanban/board.stub'), 'custom stub');

$pagesPath = $this->app->basePath('app/Filament/Pages');

$this->artisan('make:kanban TestBoard')->assertExitCode(0);

expect($pagesPath . '/TestBoard.php')
->toBeFile()
->toContainAsFile('custom stub');
});

it('loads statuses', function () {
$statuses = TaskStatus::statuses()
->pluck('title')
Expand Down