-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple select with [] in name can't be crawled #10514
Comments
Are there any steps done in dom-crawler to address this issue? |
This is the expected behaviour. |
@GrahamCampbell how would you go about testing an input/select that sends and array to the request? |
Rename it to drop the |
What do you mean rename it to drop the
How do I rename it to drop the If I change it to |
I am still on L5.1.. however, update of https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php#L845 with addition of: Would resolve the problem. |
In case anyone else finds this and is struggling to write an integration test for multiselect, I managed to get it to work by doing what @spikerok said. Taking the method @spikerok linked to : https://github.com/laravel/framework/blob/5.2/src/Illuminate/Foundation/Testing/Concerns/InteractsWithPages.php#L845 And adding in the line @spikerok said to add in: Gives you this:
Simply copy and paste that into your test case class and you should be able to run your tests just fine. Just incase you were wondering, my test looks like this:
|
@GrahamCampbell I don't think you understand why simply removing the "[]" from the name of your multiselect is a problem. It gets around the testing issue brought up here, but breaks how
|
For the time being, I've worked around this issue by submitting the form and its inputs together with Here's an example:
|
@johnberberich I didn't edit any core framework code, I simply added the storeInput method (as per my comment above) to my test case class. This way it overrides the frameworks storeInput method. |
I'm sorry, @iamthewit, I didn't read your comment thoroughly enough. I like that your solution lets you use the normal methods for filling a form, so I prefer it to mine. Thank you very much for clarifying. |
This is still a big problem with a quick and easy fix. I don't understand why this was closed. |
I'd agree that this should be re-opened - at the minute multi-value selects can't be tested with the Laravel framework. Attempting to fill in a form with a multi-select element, e.g.
With a test that includes: Fails, with the rather cryptic: Reproduced on latest Laravel. |
@pelletiermaxime if you have a fix please feel free to open a Pull Request. |
The one liner fix a few comments above worked fine for me, but my test suite is really small, so not sure if there's any chance it breaks something. I will look at making a PR in the next few days if nobody else did. |
Hello,
If you have a select, let's say it looks like
And if you try to use
It won't work, while it works in the Laravel side as soon as it goes to dom-crawler and enters the
get
function in FormFieldRegistry https://github.com/symfony/dom-crawler/blob/6bf50c092a5fcfb700e53addabb82ebd77625b27/FormFieldRegistry.php#L82 it breaks. The form field registry stores selects, regardless if they have a[]
or not without it. So in this case if I changed it toIt would work on the dom-crawler, but it won't work for the Laravel CrawlerTrait. Basically if you have
In your test, and then add something like
On https://github.com/symfony/dom-crawler/blob/6bf50c092a5fcfb700e53addabb82ebd77625b27/FormFieldRegistry.php#L84
It works.
So before the field names are sent to dom-crawler they need to have
[]
stripped.dom-crawler version - v2.7.5
laravel foundation version - v5.1.19
The text was updated successfully, but these errors were encountered: