generated from spatie/package-skeleton-laravel
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f673569
commit 613dace
Showing
12 changed files
with
214 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace Stephenjude\FilamentDebugger\Tests\Common; | ||
|
||
use Filament\Http\Middleware\Authenticate; | ||
use Filament\Http\Middleware\DisableBladeIconComponents; | ||
use Filament\Http\Middleware\DispatchServingFilamentEvent; | ||
use Filament\Panel; | ||
use Filament\PanelProvider; | ||
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse; | ||
use Illuminate\Cookie\Middleware\EncryptCookies; | ||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken; | ||
use Illuminate\Routing\Middleware\SubstituteBindings; | ||
use Illuminate\Session\Middleware\AuthenticateSession; | ||
use Illuminate\Session\Middleware\StartSession; | ||
use Illuminate\View\Middleware\ShareErrorsFromSession; | ||
|
||
class AdminPanelProvider extends PanelProvider | ||
{ | ||
public function panel(Panel $panel): Panel | ||
{ | ||
return $panel | ||
->default() | ||
->id('admin') | ||
->path('admin') | ||
->login() | ||
->middleware([ | ||
EncryptCookies::class, | ||
AddQueuedCookiesToResponse::class, | ||
StartSession::class, | ||
AuthenticateSession::class, | ||
ShareErrorsFromSession::class, | ||
VerifyCsrfToken::class, | ||
SubstituteBindings::class, | ||
DisableBladeIconComponents::class, | ||
DispatchServingFilamentEvent::class, | ||
]) | ||
->authMiddleware([ | ||
Authenticate::class, | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,131 @@ | ||
<?php | ||
|
||
use Filament\Navigation\NavigationItem; | ||
use Stephenjude\FilamentDebugger\DebuggerPlugin; | ||
|
||
it('can install configurations', function () { | ||
$this->artisan('filament-debugger:install') | ||
->expectsOutput('Laravel Horizon installed.') | ||
->expectsOutput('Laravel Telescope installed.') | ||
->expectsOutput('Filament Debugger Installed.') | ||
->assertExitCode(0); | ||
it('will not use debugging functions') | ||
->expect(['dd', 'dump', 'ddd']) | ||
->each->not->toBeUsed(); | ||
|
||
it('registers plugin', function () { | ||
$panel = filament()->getCurrentPanel()->plugin(DebuggerPlugin::make()); | ||
|
||
expect($panel->getPlugin('filament-debugger')) | ||
->not() | ||
->toThrow(Exception::class); | ||
|
||
expect($panel->getNavigationItems())->toHaveCount(3); | ||
|
||
$plugin = $panel->getPlugin('filament-debugger'); | ||
|
||
expect($plugin)->hasHorizon()->toBeTrue(); | ||
|
||
expect($plugin)->hasTelescope()->toBeTrue(); | ||
|
||
expect($plugin)->hasPulse()->toBeTrue(); | ||
}); | ||
|
||
it('can open horizon', function () { | ||
$this->get(DebuggerPlugin::horizonNavigation())->assertSuccessful(); | ||
it('authorizes plugin', function () { | ||
$panel = filament()->getCurrentPanel()->plugin(DebuggerPlugin::make()->authorize(false)); | ||
|
||
expect($panel->getNavigationItems())->toHaveCount(0); | ||
}); | ||
|
||
it('can open telescope', function () { | ||
$this->get(DebuggerPlugin::telescopeNavigation())->assertSuccessful(); | ||
it('groups plugin navigation items', function () { | ||
$panel = filament()->getCurrentPanel() | ||
->plugin( | ||
DebuggerPlugin::make()->groupNavigation( | ||
condition: fn() => true, | ||
label: 'Laravel Debuggers' | ||
) | ||
); | ||
|
||
collect($panel->getNavigationItems()) | ||
->each( | ||
fn(NavigationItem $navigationItem) => expect($navigationItem)->getGroup()->toBe('Laravel Debuggers') | ||
); | ||
}); | ||
|
||
it('customizes telescope navigation', function () { | ||
$panel = filament()->getCurrentPanel()->plugin( | ||
DebuggerPlugin::make() | ||
->horizonNavigation(false) | ||
->pulseNavigation(false) | ||
->telescopeNavigation( | ||
condition: fn() => true, | ||
label: 'Laravel Telescope', | ||
icon: 'heroicon-o-users', | ||
url: 'telescope/requests', | ||
openInNewTab: fn() => false | ||
) | ||
); | ||
|
||
expect($panel->getNavigationItems())->toHaveCount(1); | ||
|
||
/** @var NavigationItem $navigationItem */ | ||
$navigationItem = $panel->getNavigationItems()[0]; | ||
|
||
expect($navigationItem)->getLabel()->toBe('Laravel Telescope'); | ||
|
||
expect($navigationItem)->getIcon()->toBe('heroicon-o-users'); | ||
|
||
expect($navigationItem)->getUrl()->toBe('telescope/requests'); | ||
|
||
expect($navigationItem)->shouldOpenUrlInNewTab()->toBeFalse(); | ||
}); | ||
|
||
it('customizes horizon navigation', function () { | ||
$panel = filament()->getCurrentPanel()->plugin( | ||
DebuggerPlugin::make() | ||
->telescopeNavigation(false) | ||
->pulseNavigation(false) | ||
->horizonNavigation( | ||
condition: fn() => true, | ||
label: 'Laravel Horizon', | ||
icon: 'heroicon-o-users', | ||
url: url('horizon/requests'), | ||
openInNewTab: fn() => false | ||
) | ||
); | ||
|
||
expect($panel->getNavigationItems())->toHaveCount(1); | ||
|
||
/** @var NavigationItem $navigationItem */ | ||
$navigationItem = $panel->getNavigationItems()[0]; | ||
|
||
expect($navigationItem)->getLabel()->toBe('Laravel Horizon'); | ||
|
||
expect($navigationItem)->getIcon()->toBe('heroicon-o-users'); | ||
|
||
expect($navigationItem)->getUrl()->toBe(url('horizon/requests')); | ||
|
||
expect($navigationItem)->shouldOpenUrlInNewTab()->toBeFalse(); | ||
}); | ||
|
||
it('customizes pulse navigation', function () { | ||
$panel = filament()->getCurrentPanel()->plugin( | ||
DebuggerPlugin::make() | ||
->horizonNavigation(false) | ||
->telescopeNavigation(false) | ||
->pulseNavigation( | ||
condition: fn() => true, | ||
label: 'Laravel Pulse', | ||
icon: 'heroicon-o-users', | ||
url: 'pulse/requests', | ||
openInNewTab: fn() => false | ||
) | ||
); | ||
|
||
expect($panel->getNavigationItems())->toHaveCount(1); | ||
|
||
/** @var NavigationItem $navigationItem */ | ||
$navigationItem = $panel->getNavigationItems()[0]; | ||
|
||
expect($navigationItem)->getLabel()->toBe('Laravel Pulse'); | ||
|
||
expect($navigationItem)->getIcon()->toBe('heroicon-o-users'); | ||
|
||
expect($navigationItem)->getUrl()->toBe('pulse/requests'); | ||
|
||
expect($navigationItem)->shouldOpenUrlInNewTab()->toBeFalse(); | ||
}); |
Oops, something went wrong.