1

In Unit Testing, How can I set a value to the Select box options in which drop down options are rendered from Javascript ?

When I set a value, I am getting Invalidargument exception.

Note: Form is a general HTML Form

Referred links: symfony unit tests: add/modify form action

3
  • 1
    Have you tried to directly post the form without take it and populate? Commented Oct 13, 2015 at 4:49
  • @Matteo, I just checked that.. How can i get the form submitted values after posting ? Commented Oct 13, 2015 at 6:28
  • Hi! Good catch! Mark your answer as accepted so you can close the question! Commented Oct 13, 2015 at 12:48

1 Answer 1

1

Thanks for @ Matteo comments.

In Unit testing,

For setting values for the Select box, which are not available in the Drop down, Use Posting the data instead of submitting the form,

$this->client->request('POST', $postUrl, $formValueArray);

$formValueArray = array('data' => 'value');

or

$formValueArray = array( 
                'myform' => array(
                    'data' => 'value'
                ))
            );

Note: It can be used to set all the form fields which are not available in the forms.

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

Comments

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.