adrema/tests/Feature/Form/FormUpdateActionTest.php

52 lines
1.6 KiB
PHP
Raw Normal View History

2024-02-03 17:51:27 +01:00
<?php
namespace Tests\Feature\Form;
use App\Form\Models\Form;
use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Support\Facades\Storage;
2024-02-19 01:07:54 +01:00
class FormUpdateActionTest extends FormTestCase
2024-02-03 17:51:27 +01:00
{
use DatabaseTransactions;
public function testItSetsCustomAttributesOfFields(): void
{
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()->create();
$payload = FormRequest::new()->sections([
FormtemplateSectionRequest::new()->fields([
2024-02-19 01:07:54 +01:00
$this->dateField()->state(['max_today' => true]),
2024-02-03 17:51:27 +01:00
])
])->create();
$this->patchJson(route('form.update', ['form' => $form]), $payload)
->assertOk();
$form = $form->fresh();
2024-03-07 00:58:14 +01:00
$this->assertTrue($form->config->sections->get(0)->fields->get(0)->maxToday);
2024-02-03 17:51:27 +01:00
}
public function testItUpdatesActiveColumnsWhenFieldRemoved(): void
{
$this->login()->loginNami()->withoutExceptionHandling();
$form = Form::factory()
->sections([FormtemplateSectionRequest::new()->fields([
$this->textField('firstname'),
$this->textField('geb'),
$this->textField('lastname'),
])])
->create();
$payload = FormRequest::new()->sections([
FormtemplateSectionRequest::new()->fields([
$this->textField('firstname'),
])
])->create();
$this->patchJson(route('form.update', ['form' => $form]), $payload)->assertSessionDoesntHaveErrors()->assertOk();
$this->assertEquals(['firstname'], $form->fresh()->meta['active_columns']);
}
2024-02-03 17:51:27 +01:00
}