Skip to content

Commit b1657d2

Browse files
[Form] fix Context\ExecutionContextInterface mock
1 parent a677bc9 commit b1657d2

File tree

6 files changed

+34
-21
lines changed

6 files changed

+34
-21
lines changed

Test/DeprecationErrorHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class DeprecationErrorHandler
2020
{
2121
public static function handle($errorNumber, $message, $file, $line, $context)
2222
{
23-
if ($errorNumber & E_USER_DEPRECATED) {
23+
if ($errorNumber & ~E_USER_DEPRECATED) {
2424
return true;
2525
}
2626

@@ -29,7 +29,7 @@ public static function handle($errorNumber, $message, $file, $line, $context)
2929

3030
public static function handleBC($errorNumber, $message, $file, $line, $context)
3131
{
32-
if ($errorNumber & E_USER_DEPRECATED) {
32+
if ($errorNumber & ~E_USER_DEPRECATED) {
3333
return true;
3434
}
3535

Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,46 +163,46 @@ public function testGetValues()
163163

164164
public function testLegacyGetIndicesForChoices()
165165
{
166-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
166+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
167167

168168
$choices = array($this->choice1, $this->choice2);
169169
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
170170
}
171171

172172
public function testLegacyGetIndicesForChoicesPreservesKeys()
173173
{
174-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
174+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
175175

176176
$choices = array(5 => $this->choice1, 8 => $this->choice2);
177177
$this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices));
178178
}
179179

180180
public function testLegacyGetIndicesForChoicesPreservesOrder()
181181
{
182-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
182+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
183183

184184
$choices = array($this->choice2, $this->choice1);
185185
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices));
186186
}
187187

188188
public function testLegacyGetIndicesForChoicesIgnoresNonExistingChoices()
189189
{
190-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
190+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
191191

192192
$choices = array($this->choice1, $this->choice2, 'foobar');
193193
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices));
194194
}
195195

196196
public function testLegacyGetIndicesForChoicesEmpty()
197197
{
198-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
198+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
199199

200200
$this->assertSame(array(), $this->list->getIndicesForChoices(array()));
201201
}
202202

203203
public function testLegacyGetIndicesForValues()
204204
{
205-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
205+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
206206

207207
// values and indices are always the same
208208
$values = array($this->value1, $this->value2);
@@ -211,7 +211,7 @@ public function testLegacyGetIndicesForValues()
211211

212212
public function testLegacyGetIndicesForValuesPreservesKeys()
213213
{
214-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
214+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
215215

216216
// values and indices are always the same
217217
$values = array(5 => $this->value1, 8 => $this->value2);
@@ -220,23 +220,23 @@ public function testLegacyGetIndicesForValuesPreservesKeys()
220220

221221
public function testLegacyGetIndicesForValuesPreservesOrder()
222222
{
223-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
223+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
224224

225225
$values = array($this->value2, $this->value1);
226226
$this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForValues($values));
227227
}
228228

229229
public function testLegacyGetIndicesForValuesIgnoresNonExistingValues()
230230
{
231-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
231+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
232232

233233
$values = array($this->value1, $this->value2, 'foobar');
234234
$this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values));
235235
}
236236

237237
public function testLegacyGetIndicesForValuesEmpty()
238238
{
239-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
239+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
240240

241241
$this->assertSame(array(), $this->list->getIndicesForValues(array()));
242242
}

Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ public function testGetRemainingViews()
5959

6060
public function testLegacyGetIndicesForChoices()
6161
{
62-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
62+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
6363

6464
$choices = array('b', 'c');
6565
$this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices));
6666
}
6767

6868
public function testLegacyGetIndicesForValues()
6969
{
70-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
70+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
7171

7272
$values = array('b', 'c');
7373
$this->assertSame(array(1, 2), $this->list->getIndicesForValues($values));

Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public function testInitArrayThrowsExceptionIfToStringNotFound()
187187

188188
public function testLegacyGetIndicesForChoicesWithValuePath()
189189
{
190-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
190+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
191191

192192
$this->list = new ObjectChoiceList(
193193
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
@@ -204,7 +204,7 @@ public function testLegacyGetIndicesForChoicesWithValuePath()
204204

205205
public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys()
206206
{
207-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
207+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
208208

209209
$this->list = new ObjectChoiceList(
210210
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
@@ -220,7 +220,7 @@ public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys()
220220

221221
public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder()
222222
{
223-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
223+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
224224

225225
$this->list = new ObjectChoiceList(
226226
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),
@@ -236,7 +236,7 @@ public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder()
236236

237237
public function testLegacyGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices()
238238
{
239-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
239+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
240240

241241
$this->list = new ObjectChoiceList(
242242
array($this->obj1, $this->obj2, $this->obj3, $this->obj4),

Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SimpleNumericChoiceListTest extends AbstractChoiceListTest
1717
{
1818
public function testLegacyGetIndicesForChoicesDealsWithNumericChoices()
1919
{
20-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
20+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
2121

2222
// Pass choices as strings although they are integers
2323
$choices = array('0', '1');
@@ -26,7 +26,7 @@ public function testLegacyGetIndicesForChoicesDealsWithNumericChoices()
2626

2727
public function testLegacyGetIndicesForValuesDealsWithNumericValues()
2828
{
29-
$this->iniSet('error_reporting', -1 & E_USER_DEPRECATED);
29+
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
3030

3131
// Pass values as strings although they are integers
3232
$values = array('0', '1');

Tests/Extension/Validator/Constraints/FormValidatorTest.php

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

567567
private function getMockExecutionContext()
568568
{
569-
return $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
569+
$context = $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface');
570+
$validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface');
571+
$contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface');
572+
573+
$validator->expects($this->any())
574+
->method('inContext')
575+
->with($context)
576+
->will($this->returnValue($contextualValidator));
577+
578+
$context->expects($this->any())
579+
->method('getValidator')
580+
->will($this->returnValue($validator));
581+
582+
return $context;
570583
}
571584

572585
/**

0 commit comments

Comments
 (0)