luukholleman's avatar

Multi file upload testing with symfony dom crawler

I want to unit test my upload process where people can upload a file and add some album images. The attaching is files works great but i have some problems with the multiple file upload.

<input id="album" name="album[]" type="file" multiple accept="image/png,image/jpeg">

I can't manage to attach images to this field.

$this->attach($images, 'album[]');

Gives the error

Symfony\Component\CssSelector\Exception\SyntaxErrorException: Expected identifier or "*", but <delimiter "]" at 8> found.

So tried:

 $this->attach($images[0], 'album[0]');

But that also doesn't work. Any ideas? I can't find any documentation on this subject.

0 likes
4 replies
hromby's avatar

Does the attach method expect a CSS identifier as the second argument?

luukholleman's avatar
Does the attach method expect a CSS identifier as the second argument?

Nope, it expects the name of the field.

$this->attach($images, 'album');

Album needs to be an array, otherwise it won't accept multiple images on laravels side, just the first one.

Please or to participate in this conversation.