From 6769deb392a98c97f3b084da97db7812cd04bd99 Mon Sep 17 00:00:00 2001 From: Dan Harrin Date: Mon, 21 Apr 2025 13:01:26 +0100 Subject: [PATCH] assertSchemaSet --- docs/10-testing/05-testing-actions.md | 4 ++-- packages/actions/src/Testing/TestsActions.php | 13 +------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/docs/10-testing/05-testing-actions.md b/docs/10-testing/05-testing-actions.md index 1779d29794..4c4ac0122e 100644 --- a/docs/10-testing/05-testing-actions.md +++ b/docs/10-testing/05-testing-actions.md @@ -127,7 +127,7 @@ it('can validate invoice recipient email', function () { }); ``` -To check if an action is pre-filled with data, you can use the `assertActionDataSet()` method: +To check if an action is pre-filled with data, you can use the `assertSchemaSet()` method: ```php use function Pest\Livewire\livewire; @@ -140,7 +140,7 @@ it('can send invoices to the primary contact by default', function () { 'invoice' => $invoice, ]) ->mountAction('send') - ->assertActionDataSet([ + ->assertSchemaSet([ 'email' => $recipientEmail, ]) ->callMountedAction() diff --git a/packages/actions/src/Testing/TestsActions.php b/packages/actions/src/Testing/TestsActions.php index e4ad4054c7..020d650892 100644 --- a/packages/actions/src/Testing/TestsActions.php +++ b/packages/actions/src/Testing/TestsActions.php @@ -79,18 +79,7 @@ class TestsActions public function assertActionDataSet(): Closure { return function (array | Closure $data): static { - $mountedActions = $this->instance()->mountedActions; - $mountedActionIndex = array_key_last($mountedActions); - - if ($data instanceof Closure) { - $data = $data($mountedActions[$mountedActionIndex]['data'] ?? []); - } - - if (is_array($data)) { - foreach (Arr::dot($data, prepend: "mountedActions.{$mountedActionIndex}.data.") as $key => $value) { - $this->assertSet($key, $value); - } - } + $this->assertSchemaSet($data); return $this; };