public function testForm() { $form =
$this->factory->
createNamedBuilder('name', 'Symfony\Component\Form\Extension\Core\Type\FormType'
) ->
setMethod('PUT'
) ->
setAction('http://example.com'
) ->
add('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType'
) ->
add('lastName', 'Symfony\Component\Form\Extension\Core\Type\TextType'
) ->
getForm();
// include ampersands everywhere to validate escaping
$html =
$this->
renderForm($form->
createView(),
[ 'id' => 'my&id',
'attr' =>
['class' => 'my&class'
],
]);
$this->
assertMatchesXpath($html,
'/form
[
./input[@type="hidden"][@name="_method"][@value="PUT"]
/following-sibling::div
[
./div
[
./label[@for="name_firstName"]
/following-sibling::input[@type="text"][@id="name_firstName"]
]
/following-sibling::div
[
./label[@for="name_lastName"]
/following-sibling::input[@type="text"][@id="name_lastName"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(.//input)=3]
[@id="my&id"]
[@class="my&class"]
]
[@method="post"]
[@action="http://example.com"]
[@class="my&class"]
'