I'm experiencing trouble when I write my tests for a multiple select box with the Laravel 5.1 testing helpers.
I've tried both storeInput and select which is kinda much an alias for storeInput. When I'm working with a multiple select and I want the input to be formatted as an array I've created a <select name="roles[]">
but this is not testable, I can't write something like this $this->storeInput( 'roles[]', [ 1, 2 ] )
. The errors I get then are:
Symfony\Component\CssSelector\Exception\SyntaxErrorException: Expected identifier or "*", but found.`
How is this possible to go around? I've also tested with an ID but then I get the error `Unreachable field "THE_ID".
The way I did this is to create an override of storeInput as follows (I put this in my base TestCase so I could reach it from all my tests):
and then when testing a multiselect, strip off the trailing braces for the identifier you pass to this method: