public function testValidateTokenOnSubmitIfRootAndCompoundUsesFormNameAsIntentionByDefault($valid)
{
$this->tokenManager->expects($this->once())
->method('isTokenValid')
->with(new CsrfToken('FORM_NAME', 'token'))
->will($this->returnValue($valid));
$form = $this->factory
->createNamedBuilder('FORM_NAME', 'Symfony\Component\Form\Extension\Core\Type\FormType', null, array(
'csrf_field_name' => 'csrf',
'csrf_token_manager' => $this->tokenManager,
'compound' => true,
))
->add('child', 'Symfony\Component\Form\Extension\Core\Type\TextType')
->getForm();
$form->submit(array(
'child' => 'foobar',
'csrf' => 'token',
));
// Remove token from data
$this->assertSame(array('child' => 'foobar'), $form->getData());
// Validate accordingly
$this->assertSame($valid, $form->isValid());
}