-
Notifications
You must be signed in to change notification settings - Fork 8
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
Showing
12 changed files
with
219 additions
and
95 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
use Illuminate\Database\Migrations\Migration; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Support\Facades\Schema; | ||
|
||
return new class() extends Migration | ||
{ | ||
public function up() | ||
{ | ||
Schema::create('contacts', function (Blueprint $table) { | ||
$table->id(); | ||
$table->string('name'); | ||
$table->string('email'); | ||
$table->text('content'); | ||
$table->timestamps(); | ||
}); | ||
} | ||
}; |
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,88 @@ | ||
<?php | ||
|
||
namespace Coderflex\FilamentTurnstile\Tests\Fixtures; | ||
|
||
use Coderflex\FilamentTurnstile\Forms\Components\Turnstile; | ||
use Coderflex\FilamentTurnstile\Tests\Models\Contact; | ||
use Filament\Actions\Action; | ||
use Filament\Forms; | ||
use Filament\Forms\Form; | ||
use Filament\Pages\Concerns\InteractsWithFormActions; | ||
use Filament\Pages\SimplePage; | ||
use Illuminate\Contracts\View\View; | ||
|
||
class ContactUs extends SimplePage | ||
{ | ||
use InteractsWithFormActions; | ||
|
||
public ?array $data = []; | ||
|
||
public function mount(): void | ||
{ | ||
$this->form->fill(); | ||
} | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form; | ||
} | ||
|
||
protected function getForms(): array | ||
{ | ||
return [ | ||
'form' => $this->form( | ||
$this->makeForm() | ||
->schema([ | ||
Forms\Components\TextInput::make('name') | ||
->label('Name') | ||
->required(), | ||
Forms\Components\TextInput::make('email') | ||
->label('Email') | ||
->required(), | ||
Forms\Components\TextInput::make('content') | ||
->label('Content') | ||
->required(), | ||
Turnstile::make('turnstile') | ||
// ->id('cf-captcha-field') | ||
->theme('auto'), | ||
]) | ||
) | ||
->statePath('data') | ||
->model(Contact::class), | ||
]; | ||
} | ||
|
||
/** | ||
* @return array<Action | ActionGroup> | ||
*/ | ||
protected function getFormActions(): array | ||
{ | ||
return [ | ||
$this->getSendFormAction(), | ||
]; | ||
} | ||
|
||
protected function getSendFormAction(): Action | ||
{ | ||
return Action::make('Send') | ||
->label(__('Send')) | ||
->submit('send'); | ||
} | ||
|
||
protected function hasFullWidthFormActions(): bool | ||
{ | ||
return true; | ||
} | ||
|
||
public function send() | ||
{ | ||
dd($this->form->getState()); | ||
|
||
Contact::create($this->form->getState()); | ||
} | ||
|
||
public function render(): View | ||
{ | ||
return view('fixtures.contact-us'); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,10 @@ | ||
<?php | ||
|
||
namespace Coderflex\FilamentTurnstile\Tests\Models; | ||
|
||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class Contact extends Model | ||
{ | ||
protected $guarded = []; | ||
} |
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,43 @@ | ||
<?php | ||
|
||
namespace Coderflex\FilamentTurnstile\Tests; | ||
|
||
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 TurnstilePanelProvider extends PanelProvider | ||
{ | ||
public function panel(Panel $panel): Panel | ||
{ | ||
return $panel | ||
->id('turnstile') | ||
->login() | ||
->registration() | ||
->resources([]) | ||
->pages([]) | ||
->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,26 +1,15 @@ | ||
<?php | ||
|
||
use Coderflex\FilamentTurnstile\Tests\Fixtures\Login; | ||
use Coderflex\FilamentTurnstile\Tests\Fixtures\Register; | ||
use Coderflex\FilamentTurnstile\Tests\Fixtures\ContactUs; | ||
|
||
use function Pest\Livewire\livewire; | ||
|
||
it('can render login page', function () { | ||
livewire(Login::class) | ||
it('can render contact page', function () { | ||
livewire(ContactUs::class) | ||
->assertOk(); | ||
}); | ||
|
||
it('can render register page', function () { | ||
livewire(Register::class) | ||
->assertOk(); | ||
}); | ||
|
||
test('login page has captcha field', function () { | ||
livewire(Login::class) | ||
->assertFormFieldExists('cf-captcha'); | ||
}); | ||
|
||
test('register page has captcha field', function () { | ||
livewire(Register::class) | ||
->assertFormFieldExists('cf-captcha'); | ||
test('contact page has captcha field', function () { | ||
livewire(ContactUs::class) | ||
->assertFormFieldExists('cf-captcha', 'form'); | ||
}); |
Oops, something went wrong.