Skip to content

Commit 4f67780

Browse files
committed
Merge branch '2.2' into 2.3
* 2.2: [DoctrineBridge] Added type check to prevent calling clear() on arrays [Intl] Improved FormTypeCsrfExtension to use the type class as default intention if the form name is empty Fix docblock typo Conflicts: src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php
2 parents 7703515 + 9091be6 commit 4f67780

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,37 @@ public function testValidateTokenOnSubmitIfRootAndCompoundUsesTypeClassAsIntenti
278278
$this->assertSame($valid, $form->isValid());
279279
}
280280

281+
/**
282+
* @dataProvider provideBoolean
283+
*/
284+
public function testValidateTokenOnBindIfRootAndCompoundUsesTypeClassAsIntentionIfEmptyFormName($valid)
285+
{
286+
$this->csrfProvider->expects($this->once())
287+
->method('isCsrfTokenValid')
288+
->with('Symfony\Component\Form\Extension\Core\Type\FormType', 'token')
289+
->will($this->returnValue($valid));
290+
291+
$form = $this->factory
292+
->createNamedBuilder('', 'form', null, array(
293+
'csrf_field_name' => 'csrf',
294+
'csrf_provider' => $this->csrfProvider,
295+
'compound' => true,
296+
))
297+
->add('child', 'text')
298+
->getForm();
299+
300+
$form->bind(array(
301+
'child' => 'foobar',
302+
'csrf' => 'token',
303+
));
304+
305+
// Remove token from data
306+
$this->assertSame(array('child' => 'foobar'), $form->getData());
307+
308+
// Validate accordingly
309+
$this->assertSame($valid, $form->isValid());
310+
}
311+
281312
public function testFailIfRootAndCompoundAndTokenMissing()
282313
{
283314
$this->csrfProvider->expects($this->never())

0 commit comments

Comments
 (0)