Skip to content

Commit a677bc9

Browse files
[2.5] cleanup deprecated uses
1 parent 9e31562 commit a677bc9

File tree

10 files changed

+61
-77
lines changed

10 files changed

+61
-77
lines changed

Extension/Core/Type/ChoiceType.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6262
$placeholderView = new ChoiceView(null, '', $options['empty_value']);
6363

6464
// "placeholder" is a reserved index
65-
// see also ChoiceListInterface::getIndicesForChoices()
6665
$this->addSubForms($builder, array('placeholder' => $placeholderView), $options);
6766
}
6867

Forms.php

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -55,39 +55,6 @@
5555
* ->getFormFactory();
5656
* </code>
5757
*
58-
* Support for CSRF protection is provided by the CsrfExtension.
59-
* This extension needs a CSRF provider with a strong secret
60-
* (e.g. a 20 character long random string). The default
61-
* implementation for this is DefaultCsrfProvider:
62-
*
63-
* <code>
64-
* use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
65-
* use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
66-
*
67-
* $secret = 'V8a5Z97e...';
68-
* $formFactory = Forms::createFormFactoryBuilder()
69-
* ->addExtension(new CsrfExtension(new DefaultCsrfProvider($secret)))
70-
* ->getFormFactory();
71-
* </code>
72-
*
73-
* Support for the HttpFoundation is provided by the
74-
* HttpFoundationExtension. You are also advised to load the CSRF
75-
* extension with the driver for HttpFoundation's Session class:
76-
*
77-
* <code>
78-
* use Symfony\Component\HttpFoundation\Session\Session;
79-
* use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationExtension;
80-
* use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
81-
* use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
82-
*
83-
* $session = new Session();
84-
* $secret = 'V8a5Z97e...';
85-
* $formFactory = Forms::createFormFactoryBuilder()
86-
* ->addExtension(new HttpFoundationExtension())
87-
* ->addExtension(new CsrfExtension(new SessionCsrfProvider($session, $secret)))
88-
* ->getFormFactory();
89-
* </code>
90-
*
9158
* Support for the Validator component is provided by ValidatorExtension.
9259
* This extension needs a validator object to function properly:
9360
*
@@ -129,26 +96,6 @@
12996
* ->getFormFactory();
13097
* </code>
13198
*
132-
* If you also loaded the CsrfExtension, you should pass the CSRF provider
133-
* to the extension so that you can render CSRF tokens in your templates
134-
* more easily:
135-
*
136-
* <code>
137-
* use Symfony\Component\Form\Extension\Csrf\CsrfExtension;
138-
* use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider;
139-
* use Symfony\Component\Form\Extension\Templating\TemplatingExtension;
140-
*
141-
*
142-
* $secret = 'V8a5Z97e...';
143-
* $csrfProvider = new DefaultCsrfProvider($secret);
144-
* $formFactory = Forms::createFormFactoryBuilder()
145-
* ->addExtension(new CsrfExtension($csrfProvider))
146-
* ->addExtension(new TemplatingExtension($engine, $csrfProvider, array(
147-
* 'FrameworkBundle:Form',
148-
* )))
149-
* ->getFormFactory();
150-
* </code>
151-
*
15299
* @author Bernhard Schussek <[email protected]>
153100
*/
154101
final class Forms

Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,63 +161,83 @@ public function testGetValues()
161161
$this->assertSame($this->values, $this->list->getValues());
162162
}
163163

164-
public function testGetIndicesForChoices()
164+
public function testLegacyGetIndicesForChoices()
165165
{
166+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
167+
166168
$choices = array($this->choice1, $this->choice2);
167169
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
168170
}
169171

170-
public function testGetIndicesForChoicesPreservesKeys()
172+
public function testLegacyGetIndicesForChoicesPreservesKeys()
171173
{
174+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
175+
172176
$choices = array(5 => $this->choice1, 8 => $this->choice2);
173177
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
174178
}
175179

176-
public function testGetIndicesForChoicesPreservesOrder()
180+
public function testLegacyGetIndicesForChoicesPreservesOrder()
177181
{
182+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
183+
178184
$choices = array($this->choice2, $this->choice1);
179185
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
180186
}
181187

182-
public function testGetIndicesForChoicesIgnoresNonExistingChoices()
188+
public function testLegacyGetIndicesForChoicesIgnoresNonExistingChoices()
183189
{
190+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
191+
184192
$choices = array($this->choice1, $this->choice2, 'foobar');
185193
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
186194
}
187195

188-
public function testGetIndicesForChoicesEmpty()
196+
public function testLegacyGetIndicesForChoicesEmpty()
189197
{
198+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
199+
190200
$this->assertSame(array(), $this->list->getIndicesForChoices(array()));
191201
}
192202

193-
public function testGetIndicesForValues()
203+
public function testLegacyGetIndicesForValues()
194204
{
205+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
206+
195207
// values and indices are always the same
196208
$values = array($this->value1, $this->value2);
197209
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
198210
}
199211

200-
public function testGetIndicesForValuesPreservesKeys()
212+
public function testLegacyGetIndicesForValuesPreservesKeys()
201213
{
214+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
215+
202216
// values and indices are always the same
203217
$values = array(5 => $this->value1, 8 => $this->value2);
204218
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForValues($values));
205219
}
206220

207-
public function testGetIndicesForValuesPreservesOrder()
221+
public function testLegacyGetIndicesForValuesPreservesOrder()
208222
{
223+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
224+
209225
$values = array($this->value2, $this->value1);
210226
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForValues($values));
211227
}
212228

213-
public function testGetIndicesForValuesIgnoresNonExistingValues()
229+
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
214230
{
231+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
232+
215233
$values = array($this->value1, $this->value2, 'foobar');
216234
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
217235
}
218236

219-
public function testGetIndicesForValuesEmpty()
237+
public function testLegacyGetIndicesForValuesEmpty()
220238
{
239+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
240+
221241
$this->assertSame(array(), $this->list->getIndicesForValues(array()));
222242
}
223243

Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,18 @@ public function testGetRemainingViews()
5757
$this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews());
5858
}
5959

60-
public function testGetIndicesForChoices()
60+
public function testLegacyGetIndicesForChoices()
6161
{
62+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
63+
6264
$choices = array('b', 'c');
6365
$this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
6466
}
6567

66-
public function testGetIndicesForValues()
68+
public function testLegacyGetIndicesForValues()
6769
{
70+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
71+
6872
$values = array('b', 'c');
6973
$this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));
7074
}

Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ public function testInitArrayThrowsExceptionIfToStringNotFound()
185185
);
186186
}
187187

188-
public function testGetIndicesForChoicesWithValuePath()
188+
public function testLegacyGetIndicesForChoicesWithValuePath()
189189
{
190+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
191+
190192
$this->list = new ObjectChoiceList(
191193
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
192194
'name',
@@ -200,8 +202,10 @@ public function testGetIndicesForChoicesWithValuePath()
200202
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
201203
}
202204

203-
public function testGetIndicesForChoicesWithValuePathPreservesKeys()
205+
public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys()
204206
{
207+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
208+
205209
$this->list = new ObjectChoiceList(
206210
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
207211
'name',
@@ -214,8 +218,10 @@ public function testGetIndicesForChoicesWithValuePathPreservesKeys()
214218
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
215219
}
216220

217-
public function testGetIndicesForChoicesWithValuePathPreservesOrder()
221+
public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder()
218222
{
223+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
224+
219225
$this->list = new ObjectChoiceList(
220226
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
221227
'name',
@@ -228,8 +234,10 @@ public function testGetIndicesForChoicesWithValuePathPreservesOrder()
228234
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
229235
}
230236

231-
public function testGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
237+
public function testLegacyGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
232238
{
239+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
240+
233241
$this->list = new ObjectChoiceList(
234242
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
235243
'name',

Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,19 @@
1515

1616
class SimpleNumericChoiceListTest extends AbstractChoiceListTest
1717
{
18-
public function testGetIndicesForChoicesDealsWithNumericChoices()
18+
public function testLegacyGetIndicesForChoicesDealsWithNumericChoices()
1919
{
20+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
21+
2022
// Pass choices as strings although they are integers
2123
$choices = array('0', '1');
2224
$this->assertSame(array(0, 1), $this->list->getIndicesForChoices($choices));
2325
}
2426

25-
public function testGetIndicesForValuesDealsWithNumericValues()
27+
public function testLegacyGetIndicesForValuesDealsWithNumericValues()
2628
{
29+
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
30+
2731
// Pass values as strings although they are integers
2832
$values = array('0', '1');
2933
$this->assertSame(array(0, 1), $this->list->getIndicesForValues($values));

Tests/Extension/Csrf/CsrfProvider/SessionCsrfProviderTest.php renamed to Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@
1313

1414
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider;
1515

16-
class SessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
16+
class LegacySessionCsrfProviderTest extends \PHPUnit_Framework_TestCase
1717
{
1818
protected $provider;
1919
protected $session;
2020

2121
protected function setUp()
2222
{
23+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
24+
2325
$this->session = $this->getMock(
2426
'Symfony\Component\HttpFoundation\Session\Session',
2527
array(),

Tests/Extension/Validator/Constraints/FormValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ public function getValidationGroups(FormInterface $form)
566566

567567
private function getMockExecutionContext()
568568
{
569-
return $this->getMock('Symfony\Component\Validator\ExecutionContextInterface');
569+
return $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
570570
}
571571

572572
/**

Tests/SimpleFormTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,16 @@ public function testDataIsInitializedFromSubmit()
100100
public function testFalseIsConvertedToNull()
101101
{
102102
$mock = $this->getMockBuilder('\stdClass')
103-
->setMethods(array('preBind'))
103+
->setMethods(array('preSubmit'))
104104
->getMock();
105105
$mock->expects($this->once())
106-
->method('preBind')
106+
->method('preSubmit')
107107
->with($this->callback(function ($event) {
108108
return null === $event->getData();
109109
}));
110110

111111
$config = new FormConfigBuilder('name', null, $this->dispatcher);
112-
$config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preBind'));
112+
$config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit'));
113113
$form = new Form($config);
114114

115115
$form->submit(false);

0 commit comments

Comments
 (0)