Testing a form action.
Hey,
I have the following action on my ListUsers field:
Now I am trying to write a test:
I am getting an error: failed asserting an action with the name [send] exists.
I am not sure how to continue. I have a button, when I press that button a form loads and I want to test that when I press that button, en email is sent.
Thanks for your help.
Solution:Jump to solution
I think
```php
->callAction('nodigGebruikerUit')
->set('mountedActionsData.0.email', 'test@example.com')
->callMountedAction()...
15 Replies
Send don’t exist on the action. It’s on the Mail facade. Calling the action will trigger the send. You shouldn’t need to manually call it.
The error is before the Mail facade
I think it doesn’t show the form.
Right, but you are trying to call an action named ‘send’ which doesn’t exist.
Ok. So
1. How do I trigger the form in my test.
2. How do I send the form?
You need to setup the action with the data it needs before calling in. So, you would mountAction() with the data for the form. Then callAction()
Solution
I think
not sure if fillForm works
This works. Thanks so much.
Testing is hard.....
hum, this will work
What is the difference between callAction and callMountedAction?
callAction will execute the action. If you have a form, this will open the form. So, you need to run callMountedAction to submit it
Actually, If you are using the second example passing the data, I think you don't need to run
callMountedAction
. callAction
will submit the formI tested it, and it works indeed
Thanks soo much
Thanks I did read that page. I found it hard to understand maybe because it has just examples of the tests but not of the actual code.
you sometimes need to dive into the source code to understand how it works..
I was looking for the callAction method. But I couldn't find it then. Now I am searching again and there it is 🙄