Skip to content

Commit ece2457

Browse files
Merge branch '2.7' into 2.8
* 2.7: Refactoring tests.
2 parents 783a5f8 + 1e873e3 commit ece2457

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

Tests/CompoundFormTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -309,12 +309,12 @@ public function testArrayAccess()
309309

310310
$this->form[] = $child;
311311

312-
$this->assertTrue(isset($this->form['foo']));
312+
$this->assertArrayHasKey('foo', $this->form);
313313
$this->assertSame($child, $this->form['foo']);
314314

315315
unset($this->form['foo']);
316316

317-
$this->assertFalse(isset($this->form['foo']));
317+
$this->assertArrayNotHasKey('foo', $this->form);
318318
}
319319

320320
public function testCountable()

Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice()
252252
'choices_as_values' => true,
253253
));
254254

255-
$this->assertTrue(isset($form['placeholder']));
255+
$this->assertArrayHasKey('placeholder', $form);
256256
$this->assertCount(count($this->choices) + 1, $form, 'Each choice should become a new field');
257257
}
258258

@@ -266,7 +266,7 @@ public function testPlaceholderNotPresentIfRequired()
266266
'choices_as_values' => true,
267267
));
268268

269-
$this->assertFalse(isset($form['placeholder']));
269+
$this->assertArrayNotHasKey('placeholder', $form);
270270
$this->assertCount(count($this->choices), $form, 'Each choice should become a new field');
271271
}
272272

@@ -280,7 +280,7 @@ public function testPlaceholderNotPresentIfMultiple()
280280
'choices_as_values' => true,
281281
));
282282

283-
$this->assertFalse(isset($form['placeholder']));
283+
$this->assertArrayNotHasKey('placeholder', $form);
284284
$this->assertCount(count($this->choices), $form, 'Each choice should become a new field');
285285
}
286286

@@ -297,7 +297,7 @@ public function testPlaceholderNotPresentIfEmptyChoice()
297297
'choices_as_values' => true,
298298
));
299299

300-
$this->assertFalse(isset($form['placeholder']));
300+
$this->assertArrayNotHasKey('placeholder', $form);
301301
$this->assertCount(2, $form, 'Each choice should become a new field');
302302
}
303303

@@ -357,7 +357,7 @@ public function testPlaceholderWithExpandedBooleanChoices()
357357
'choices_as_values' => true,
358358
));
359359

360-
$this->assertTrue(isset($form['placeholder']), 'Placeholder should be set');
360+
$this->assertArrayHasKey('placeholder', $form, 'Placeholder should be set');
361361
$this->assertCount(3, $form, 'Each choice should become a new field, placeholder included');
362362

363363
$view = $form->createView();
@@ -382,7 +382,7 @@ public function testPlaceholderWithExpandedBooleanChoicesAndWithFalseAsPreSetDat
382382
'choices_as_values' => true,
383383
));
384384

385-
$this->assertTrue(isset($form['placeholder']), 'Placeholder should be set');
385+
$this->assertArrayHasKey('placeholder', $form, 'Placeholder should be set');
386386
$this->assertCount(3, $form, 'Each choice should become a new field, placeholder included');
387387

388388
$view = $form->createView();

Tests/Extension/Core/Type/CollectionTypeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testSetDataAdjustsSize()
6060

6161
$form->setData(array('[email protected]'));
6262
$this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]);
63-
$this->assertFalse(isset($form[1]));
63+
$this->assertArrayNotHasKey(1, $form);
6464
$this->assertCount(1, $form);
6565
$this->assertEquals('[email protected]', $form[0]->getData());
6666
$formAttrs0 = $form[0]->getConfig()->getOption('attr');
@@ -239,7 +239,7 @@ public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet()
239239
));
240240

241241
$data = $form->getData();
242-
$this->assertFalse(isset($data['__name__']));
242+
$this->assertArrayNotHasKey('__name__', $data);
243243
}
244244

245245
public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
@@ -252,7 +252,7 @@ public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
252252

253253
$form->setData(array('foobar.png'));
254254
$data = $form->getData();
255-
$this->assertFalse(isset($data['__name__']));
255+
$this->assertArrayNotHasKey('__name__', $data);
256256
}
257257

258258
public function testPrototypeNameOption()

Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed()
454454
))
455455
->createView();
456456

457-
$this->assertFalse(isset($view->vars['type']));
457+
$this->assertArrayNotHasKey('type', $view->vars);
458458
}
459459

460460
public function testDontPassHtml5TypeIfNotHtml5Format()
@@ -465,7 +465,7 @@ public function testDontPassHtml5TypeIfNotHtml5Format()
465465
))
466466
->createView();
467467

468-
$this->assertFalse(isset($view->vars['type']));
468+
$this->assertArrayNotHasKey('type', $view->vars);
469469
}
470470

471471
public function testDontPassHtml5TypeIfNotSingleText()
@@ -475,7 +475,7 @@ public function testDontPassHtml5TypeIfNotSingleText()
475475
))
476476
->createView();
477477

478-
$this->assertFalse(isset($view->vars['type']));
478+
$this->assertArrayNotHasKey('type', $view->vars);
479479
}
480480

481481
public function testDateTypeChoiceErrorsBubbleUp()

Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -688,7 +688,7 @@ public function testDontPassDatePatternIfText()
688688
))
689689
->createView();
690690

691-
$this->assertFalse(isset($view->vars['date_pattern']));
691+
$this->assertArrayNotHasKey('date_pattern', $view->vars);
692692
}
693693

694694
public function testDatePatternFormatWithQuotedStrings()
@@ -854,7 +854,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed()
854854
))
855855
->createView();
856856

857-
$this->assertFalse(isset($view->vars['type']));
857+
$this->assertArrayNotHasKey('type', $view->vars);
858858
}
859859

860860
public function testDontPassHtml5TypeIfNotHtml5Format()
@@ -865,7 +865,7 @@ public function testDontPassHtml5TypeIfNotHtml5Format()
865865
))
866866
->createView();
867867

868-
$this->assertFalse(isset($view->vars['type']));
868+
$this->assertArrayNotHasKey('type', $view->vars);
869869
}
870870

871871
public function testDontPassHtml5TypeIfNotSingleText()
@@ -875,7 +875,7 @@ public function testDontPassHtml5TypeIfNotSingleText()
875875
))
876876
->createView();
877877

878-
$this->assertFalse(isset($view->vars['type']));
878+
$this->assertArrayNotHasKey('type', $view->vars);
879879
}
880880

881881
public function provideCompoundWidgets()

Tests/Extension/Core/Type/TimeTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed()
546546
));
547547

548548
$view = $form->createView();
549-
$this->assertFalse(isset($view->vars['type']));
549+
$this->assertArrayNotHasKey('type', $view->vars);
550550
}
551551

552552
public function testPassDefaultPlaceholderToViewIfNotRequired()

Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testCsrfProtectionByDefaultIfRootAndCompound()
7272
))
7373
->createView();
7474

75-
$this->assertTrue(isset($view['csrf']));
75+
$this->assertArrayHasKey('csrf', $view);
7676
}
7777

7878
public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot()
@@ -89,7 +89,7 @@ public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot()
8989
->get('form')
9090
->createView();
9191

92-
$this->assertFalse(isset($view['csrf']));
92+
$this->assertArrayNotHasKey('csrf', $view);
9393
}
9494

9595
public function testNoCsrfProtectionByDefaultIfRootButNotCompound()
@@ -101,7 +101,7 @@ public function testNoCsrfProtectionByDefaultIfRootButNotCompound()
101101
))
102102
->createView();
103103

104-
$this->assertFalse(isset($view['csrf']));
104+
$this->assertArrayNotHasKey('csrf', $view);
105105
}
106106

107107
public function testCsrfProtectionCanBeDisabled()
@@ -114,7 +114,7 @@ public function testCsrfProtectionCanBeDisabled()
114114
))
115115
->createView();
116116

117-
$this->assertFalse(isset($view['csrf']));
117+
$this->assertArrayNotHasKey('csrf', $view);
118118
}
119119

120120
public function testGenerateCsrfToken()
@@ -357,7 +357,7 @@ public function testNoCsrfProtectionOnPrototype()
357357
->createView()
358358
->vars['prototype'];
359359

360-
$this->assertFalse(isset($prototypeView['csrf']));
360+
$this->assertArrayNotHasKey('csrf', $prototypeView);
361361
$this->assertCount(1, $prototypeView);
362362
}
363363

Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function testCreatePath($string, $entries, $slicedPath = null)
9696
$path = new ViolationPath($string);
9797

9898
$this->assertSame($slicedPath, $path->__toString());
99-
$this->assertSame(count($entries), count($path->getElements()));
99+
$this->assertCount(count($entries), $path->getElements());
100100
$this->assertSame(count($entries), $path->getLength());
101101

102102
foreach ($entries as $index => $entry) {

Tests/Util/OrderedHashMapTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,22 @@ public function testIsset()
9191
$map = new OrderedHashMap();
9292
$map['first'] = 1;
9393

94-
$this->assertTrue(isset($map['first']));
94+
$this->assertArrayHasKey('first', $map);
9595
}
9696

9797
public function testIssetReturnsFalseForNonExisting()
9898
{
9999
$map = new OrderedHashMap();
100100

101-
$this->assertFalse(isset($map['first']));
101+
$this->assertArrayNotHasKey('first', $map);
102102
}
103103

104104
public function testIssetReturnsFalseForNull()
105105
{
106106
$map = new OrderedHashMap();
107107
$map['first'] = null;
108108

109-
$this->assertFalse(isset($map['first']));
109+
$this->assertArrayNotHasKey('first', $map);
110110
}
111111

112112
public function testUnset()

0 commit comments

Comments
 (0)