Add FormtemplateUpdateActionTest
This commit is contained in:
parent
f55c174019
commit
5b2a290b49
|
@ -3,6 +3,7 @@
|
|||
namespace App\Form\Actions;
|
||||
|
||||
use App\Form\Models\Formtemplate;
|
||||
use App\Lib\Events\Succeeded;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lorisleiva\Actions\ActionRequest;
|
||||
use Lorisleiva\Actions\Concerns\AsAction;
|
||||
|
@ -35,6 +36,8 @@ class FormtemplateUpdateAction
|
|||
{
|
||||
$this->handle($formtemplate, $request->validated());
|
||||
|
||||
Succeeded::message('Vorlage aktualisiert.')->dispatch();
|
||||
|
||||
return response()->json([]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
|
||||
namespace Tests\Feature\Form;
|
||||
|
||||
use App\Form\Models\Formtemplate;
|
||||
use App\Lib\Events\Succeeded;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FormtemplateUpdateActionTest extends TestCase
|
||||
|
@ -10,23 +13,20 @@ class FormtemplateUpdateActionTest extends TestCase
|
|||
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function testItStoresTemplates(): void
|
||||
public function testItUpdatesTemplates(): void
|
||||
{
|
||||
Event::fake([Succeeded::class]);
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$formtemplate = Formtemplate::factory()->create();
|
||||
FormtemplateRequest::new()->name('testname')->fake();
|
||||
|
||||
$this->postJson(route('formtemplate.store'), [
|
||||
'name' => 'Testname',
|
||||
'config' => [
|
||||
'sections' => [
|
||||
['name' => 'Persönliches', 'fields' => []]
|
||||
]
|
||||
]
|
||||
])->assertOk();
|
||||
$this->patchJson(route('formtemplate.update', ['formtemplate' => $formtemplate]))
|
||||
->assertOk();
|
||||
|
||||
$this->assertDatabaseHas('formtemplates', [
|
||||
'name' => 'Testname',
|
||||
'config' => json_encode(['sections' => [['name' => 'Persönliches', 'fields' => []]]]),
|
||||
]);
|
||||
Event::assertDispatched(Succeeded::class, fn (Succeeded $event) => $event->message === 'Vorlage aktualisiert.');
|
||||
}
|
||||
|
||||
public function testNameIsRequired(): void
|
||||
|
|
Loading…
Reference in New Issue