adrema/tests/Feature/Form/IsDirtyActionTest.php

26 lines
787 B
PHP
Raw Normal View History

2024-04-19 11:38:53 +02:00
<?php
namespace Tests\Feature\Form;
use App\Form\Models\Form;
use Illuminate\Foundation\Testing\DatabaseTransactions;
class IsDirtyActionTest extends FormTestCase
{
use DatabaseTransactions;
public function testItChecksIfFormIsDirty(): void
{
$this->login()->loginNami();
$form = Form::factory()->fields([
$this->textField(),
])->create();
$this->postJson(route('form.is-dirty', ['form' => $form]), ['config' => $form->config->toArray()])->assertJsonPath('result', false);
$modifiedConfig = $form->config->toArray();
data_set($modifiedConfig, 'sections.0.name', 'mod');
$this->postJson(route('form.is-dirty', ['form' => $form]), ['config' => $modifiedConfig])->assertJsonPath('result', true);
}
}