Fix tests

This commit is contained in:
philipp lang 2024-02-18 00:25:44 +01:00
parent 974c73af71
commit a830f366ad
1 changed files with 5 additions and 3 deletions

View File

@ -16,6 +16,7 @@ use App\Form\Fields\TextField;
use App\Form\Models\Form; use App\Form\Models\Form;
use App\Group; use App\Group;
use App\Member\Member; use App\Member\Member;
use Carbon\Carbon;
use Generator; use Generator;
use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Foundation\Testing\DatabaseTransactions;
use Tests\TestCase; use Tests\TestCase;
@ -65,6 +66,7 @@ class FormRegisterActionTest extends TestCase
*/ */
public function testItValidatesInput(FormtemplateFieldRequest $fieldGenerator, array $payload, ?array $messages): void public function testItValidatesInput(FormtemplateFieldRequest $fieldGenerator, array $payload, ?array $messages): void
{ {
Carbon::setTestNow(Carbon::parse('2024-02-15 06:00:00'));
$this->login()->loginNami(); $this->login()->loginNami();
$form = Form::factory() $form = Form::factory()
->sections([FormtemplateSectionRequest::new()->fields([$fieldGenerator])]) ->sections([FormtemplateSectionRequest::new()->fields([$fieldGenerator])])
@ -95,13 +97,13 @@ class FormRegisterActionTest extends TestCase
yield [ yield [
FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(true)->key('birthday'), FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(true)->key('birthday'),
['birthday' => now()->addDay()->format('Y-m-d')], ['birthday' => '2024-02-16'],
['birthday' => 'Geburtsdatum muss ein Datum vor oder gleich dem ' . now()->format('d.m.Y') . ' sein.'], ['birthday' => 'Geburtsdatum muss ein Datum vor oder gleich dem 15.02.2024 sein.'],
]; ];
yield [ yield [
FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(true)->key('birthday'), FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(true)->key('birthday'),
['birthday' => now()->format('Y-m-d')], ['birthday' => '2024-02-15'],
null, null,
]; ];