adrema/modules/Form/Components/SettingViewTest.php

43 lines
1.5 KiB
PHP

<?php
namespace Modules\Form\Components;
use App\Form\FormSettings;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Livewire\Livewire;
use Tests\TestCase;
uses(TestCase::class);
uses(DatabaseTransactions::class);
it('it renders page', function () {
test()->withoutExceptionHandling()->login()->loginNami();
test()->get('/setting/form')->assertSeeLivewire(SettingView::class);
});
it('it displays active modules', function () {
test()->withoutExceptionHandling()->login()->loginNami();
app(FormSettings::class)->fill(['registerUrl' => 'http://example.com/register', 'clearCacheUrl' => 'http://example.com/clear-cache'])->save();
Livewire::test(SettingView::class)
->assertSee('Einstellungen für Anmeldeformulare')
->assertSee('Formular-Link')
->assertSet('registerUrl', 'http://example.com/register')
->assertSet('clearCacheUrl', 'http://example.com/clear-cache')
->assertSeeHtml('data-active');
});
it('it saves settings', function () {
test()->withoutExceptionHandling()->login()->loginNami();
Livewire::test(SettingView::class)
->set('clearCacheUrl', 'http://example.com/clear')
->set('registerUrl', 'http://example.com/register')
->call('save')
->assertDispatched('success', 'Einstellungen gespeichert.');
test()->assertEquals('http://example.com/clear', app(FormSettings::class)->clearCacheUrl);
test()->assertEquals('http://example.com/register', app(FormSettings::class)->registerUrl);
});