Skip to content

Commit

Permalink
Removed some leaking deprecation warning in the Form component
Browse files Browse the repository at this point in the history
Fixes #7101
  • Loading branch information
stof authored and fabpot committed Feb 19, 2013
1 parent 95a8aa5 commit 189fba6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 31 deletions.
42 changes: 21 additions & 21 deletions src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php
Expand Up @@ -209,7 +209,7 @@ public function testSetDataSingleNull()
$field->setData(null);

$this->assertNull($field->getData());
$this->assertSame('', $field->getClientData());
$this->assertSame('', $field->getViewData());
}

public function testSetDataMultipleExpandedNull()
Expand All @@ -223,7 +223,7 @@ public function testSetDataMultipleExpandedNull()
$field->setData(null);

$this->assertNull($field->getData());
$this->assertSame(array(), $field->getClientData());
$this->assertSame(array(), $field->getViewData());
}

public function testSetDataMultipleNonExpandedNull()
Expand All @@ -237,7 +237,7 @@ public function testSetDataMultipleNonExpandedNull()
$field->setData(null);

$this->assertNull($field->getData());
$this->assertSame(array(), $field->getClientData());
$this->assertSame(array(), $field->getViewData());
}

public function testSubmitSingleExpandedNull()
Expand All @@ -251,7 +251,7 @@ public function testSubmitSingleExpandedNull()
$field->bind(null);

$this->assertNull($field->getData());
$this->assertSame(array(), $field->getClientData());
$this->assertSame(array(), $field->getViewData());
}

public function testSubmitSingleNonExpandedNull()
Expand All @@ -265,7 +265,7 @@ public function testSubmitSingleNonExpandedNull()
$field->bind(null);

$this->assertNull($field->getData());
$this->assertSame('', $field->getClientData());
$this->assertSame('', $field->getViewData());
}

public function testSubmitMultipleNull()
Expand All @@ -278,7 +278,7 @@ public function testSubmitMultipleNull()
$field->bind(null);

$this->assertEquals(new ArrayCollection(), $field->getData());
$this->assertSame(array(), $field->getClientData());
$this->assertSame(array(), $field->getViewData());
}

public function testSubmitSingleNonExpandedSingleIdentifier()
Expand All @@ -300,7 +300,7 @@ public function testSubmitSingleNonExpandedSingleIdentifier()

$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
$this->assertSame('2', $field->getClientData());
$this->assertSame('2', $field->getViewData());
}

public function testSubmitSingleNonExpandedCompositeIdentifier()
Expand All @@ -323,7 +323,7 @@ public function testSubmitSingleNonExpandedCompositeIdentifier()

$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
$this->assertSame('1', $field->getClientData());
$this->assertSame('1', $field->getViewData());
}

public function testSubmitMultipleNonExpandedSingleIdentifier()
Expand All @@ -348,7 +348,7 @@ public function testSubmitMultipleNonExpandedSingleIdentifier()

$this->assertTrue($field->isSynchronized());
$this->assertEquals($expected, $field->getData());
$this->assertSame(array('1', '3'), $field->getClientData());
$this->assertSame(array('1', '3'), $field->getViewData());
}

public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData()
Expand Down Expand Up @@ -379,7 +379,7 @@ public function testSubmitMultipleNonExpandedSingleIdentifierForExistingData()
$this->assertEquals($expected, $field->getData());
// same object still, useful if it is a PersistentCollection
$this->assertSame($existing, $field->getData());
$this->assertSame(array('1', '3'), $field->getClientData());
$this->assertSame(array('1', '3'), $field->getViewData());
}

public function testSubmitMultipleNonExpandedCompositeIdentifier()
Expand All @@ -405,7 +405,7 @@ public function testSubmitMultipleNonExpandedCompositeIdentifier()

$this->assertTrue($field->isSynchronized());
$this->assertEquals($expected, $field->getData());
$this->assertSame(array('0', '2'), $field->getClientData());
$this->assertSame(array('0', '2'), $field->getViewData());
}

public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData()
Expand Down Expand Up @@ -436,7 +436,7 @@ public function testSubmitMultipleNonExpandedCompositeIdentifierExistingData()
$this->assertEquals($expected, $field->getData());
// same object still, useful if it is a PersistentCollection
$this->assertSame($existing, $field->getData());
$this->assertSame(array('0', '2'), $field->getClientData());
$this->assertSame(array('0', '2'), $field->getViewData());
}

public function testSubmitSingleExpanded()
Expand All @@ -460,8 +460,8 @@ public function testSubmitSingleExpanded()
$this->assertSame($entity2, $field->getData());
$this->assertFalse($field['1']->getData());
$this->assertTrue($field['2']->getData());
$this->assertNull($field['1']->getClientData());
$this->assertSame('2', $field['2']->getClientData());
$this->assertNull($field['1']->getViewData());
$this->assertSame('2', $field['2']->getViewData());
}

public function testSubmitMultipleExpanded()
Expand Down Expand Up @@ -489,9 +489,9 @@ public function testSubmitMultipleExpanded()
$this->assertTrue($field['1']->getData());
$this->assertFalse($field['2']->getData());
$this->assertTrue($field['3']->getData());
$this->assertSame('1', $field['1']->getClientData());
$this->assertNull($field['2']->getClientData());
$this->assertSame('3', $field['3']->getClientData());
$this->assertSame('1', $field['1']->getViewData());
$this->assertNull($field['2']->getViewData());
$this->assertSame('3', $field['3']->getViewData());
}

public function testOverrideChoices()
Expand All @@ -515,7 +515,7 @@ public function testOverrideChoices()
$this->assertEquals(array(1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar')), $field->createView()->vars['choices']);
$this->assertTrue($field->isSynchronized());
$this->assertSame($entity2, $field->getData());
$this->assertSame('2', $field->getClientData());
$this->assertSame('2', $field->getViewData());
}

public function testGroupByChoices()
Expand All @@ -537,7 +537,7 @@ public function testGroupByChoices()

$field->bind('2');

$this->assertSame('2', $field->getClientData());
$this->assertSame('2', $field->getViewData());
$this->assertEquals(array(
'Group1' => array(1 => new ChoiceView($item1, '1', 'Foo'), 2 => new ChoiceView($item2, '2', 'Bar')),
'Group2' => array(3 => new ChoiceView($item3, '3', 'Baz')),
Expand Down Expand Up @@ -716,7 +716,7 @@ public function testSubmitSingleStringIdentifier()

$this->assertTrue($field->isSynchronized());
$this->assertSame($entity1, $field->getData());
$this->assertSame('foo', $field->getClientData());
$this->assertSame('foo', $field->getViewData());
}

public function testSubmitCompositeStringIdentifier()
Expand All @@ -738,7 +738,7 @@ public function testSubmitCompositeStringIdentifier()

$this->assertTrue($field->isSynchronized());
$this->assertSame($entity1, $field->getData());
$this->assertSame('0', $field->getClientData());
$this->assertSame('0', $field->getViewData());
}

public function testGetManagerForClassIfNoEm()
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Form/ResolvedFormType.php
Expand Up @@ -62,7 +62,9 @@ public function __construct(FormTypeInterface $innerType, array $typeExtensions
// BC
if ($innerType instanceof AbstractType) {
/* @var AbstractType $innerType */
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handleBC'));
$innerType->setExtensions($typeExtensions);
restore_error_handler();
}

$this->innerType = $innerType;
Expand Down
Expand Up @@ -601,9 +601,11 @@ public function testPropertyPathNullImpliesDefault()
// BC
public function testPropertyPathFalseImpliesDefaultNotMapped()
{
set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
$form = $this->factory->createNamed('name', 'form', null, array(
'property_path' => false,
));
restore_error_handler();

$this->assertEquals(new PropertyPath('name'), $form->getPropertyPath());
$this->assertFalse($form->getConfig()->getMapped());
Expand Down
Expand Up @@ -42,7 +42,7 @@ public function testPassDifferentPatternsForDifferentCurrencies()
$view1 = $form1->createView();
$view2 = $form2->createView();

$this->assertSame('{{ widget }} £', $view1->get('money_pattern'));
$this->assertSame('{{ widget }} €', $view2->get('money_pattern'));
$this->assertSame('{{ widget }} £', $view1->vars['money_pattern']);
$this->assertSame('{{ widget }} €', $view2->vars['money_pattern']);
}
}
Expand Up @@ -231,7 +231,7 @@ public function testSetDataWithoutMinutes()

$form->setData(new \DateTime('03:04:05 UTC'));

$this->assertEquals(array('hour' => 3), $form->getClientData());
$this->assertEquals(array('hour' => 3), $form->getViewData());
}

public function testSetDataWithSeconds()
Expand Down
7 changes: 0 additions & 7 deletions src/Symfony/Component/Form/Tests/FormIntegrationTestCase.php
Expand Up @@ -32,13 +32,6 @@ protected function setUp()
$this->factory = Forms::createFormFactoryBuilder()
->addExtensions($this->getExtensions())
->getFormFactory();

set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle'));
}

protected function tearDown()
{
restore_error_handler();
}

protected function getExtensions()
Expand Down

0 comments on commit 189fba6

Please sign in to comment.