Select Symfony2 Radio Button Functional Test

I am doing some functional tests with symfony2. I want to select a radio button in a basic form:

<form method="post" action="mylink">
    <input id="position_51" type="radio" name="user_position" value="51"> 
    <input id="position_52" type="radio" name="user_position" value="52"> 
    <input id="position_54" type="radio" name="user_position" value="54"> 
    <input id="position_57" type="radio" name="user_position" value="57"> 
    <button id="bt_submit" type="submit">Submit</button>
</form>

      

So I choose the shape

$buttonFrom = $client->getCrawler()->selectButton('bt_submit');
$form = $buttonFrom->form();

      

Now if I want to select a radio with a specific identifier like "position_54" and check it. How to do it? In all the examples I've found tick () seems to be used in the name attribute for input ... It doesn't help me with the radio button.

$ form ['user_position'] doesn't look like an array ...

thank

+3


source to share


1 answer


As the symfony doc says about testing , you can select an option or radio as follows:

$form['user_position']->select('51');

      



Here is the API for ChoiceFormField .

+3


source







All Articles