3

I'm writing some tests for a form I've written in Laravel 5.1 but I'm getting an error saying:

Symfony\Component\CssSelector\Exception\SyntaxErrorException: Expected identifier or "*", but <number "1" at 11> found.

The issue is that I'm using 'array' names for some of my fields.

It's a series of questions and I'm using the question ID to map answers:

<label>Your answer for question 1?
    <textarea name="question[1]"></textarea>
<label>
<label>Your answer for question 2?
    <textarea name="question[2]"></textarea>
<label>

Then my test looks like this:

$response = $this->actingAs($user)
        ->visit('/application/project/1/1')
        ->type('This is a new title', 'title')
        ->type('My Question one Answer', 'question[1]')
        ->press('Save & Next Page');

I assume I need to present question[1] differently but I can't see how.

1 Answer 1

2

A way you can get around this is by using the submitForm method.

$input = [
    'title' => 'This is my new title',
    'question[1]' => 'My Question one answer'
];
$response = $this->actingAs($user)
    ->visit('/application/project/1/1')
    ->submitForm('Save & Next Page', $input);

Hope this helps!

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect. Thanks so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.