Skip to content

Commit 1e873e3

Browse files
committed
Refactoring tests.
1 parent f975ef0 commit 1e873e3

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
@@ -243,7 +243,7 @@ public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice()
243243
'choices_as_values' => true,
244244
));
245245

246-
$this->assertTrue(isset($form['placeholder']));
246+
$this->assertArrayHasKey('placeholder', $form);
247247
$this->assertCount(count($this->choices) + 1, $form, 'Each choice should become a new field');
248248
}
249249

@@ -257,7 +257,7 @@ public function testPlaceholderNotPresentIfRequired()
257257
'choices_as_values' => true,
258258
));
259259

260-
$this->assertFalse(isset($form['placeholder']));
260+
$this->assertArrayNotHasKey('placeholder', $form);
261261
$this->assertCount(count($this->choices), $form, 'Each choice should become a new field');
262262
}
263263

@@ -271,7 +271,7 @@ public function testPlaceholderNotPresentIfMultiple()
271271
'choices_as_values' => true,
272272
));
273273

274-
$this->assertFalse(isset($form['placeholder']));
274+
$this->assertArrayNotHasKey('placeholder', $form);
275275
$this->assertCount(count($this->choices), $form, 'Each choice should become a new field');
276276
}
277277

@@ -288,7 +288,7 @@ public function testPlaceholderNotPresentIfEmptyChoice()
288288
'choices_as_values' => true,
289289
));
290290

291-
$this->assertFalse(isset($form['placeholder']));
291+
$this->assertArrayNotHasKey('placeholder', $form);
292292
$this->assertCount(2, $form, 'Each choice should become a new field');
293293
}
294294

@@ -348,7 +348,7 @@ public function testPlaceholderWithExpandedBooleanChoices()
348348
'choices_as_values' => true,
349349
));
350350

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

354354
$view = $form->createView();
@@ -373,7 +373,7 @@ public function testPlaceholderWithExpandedBooleanChoicesAndWithFalseAsPreSetDat
373373
'choices_as_values' => true,
374374
));
375375

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

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

Tests/Extension/Core/Type/CollectionTypeTest.php

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

5050
$form->setData(array('[email protected]'));
5151
$this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]);
52-
$this->assertFalse(isset($form[1]));
52+
$this->assertArrayNotHasKey(1, $form);
5353
$this->assertCount(1, $form);
5454
$this->assertEquals('[email protected]', $form[0]->getData());
5555
$formAttrs0 = $form[0]->getConfig()->getOption('attr');
@@ -228,7 +228,7 @@ public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet()
228228
));
229229

230230
$data = $form->getData();
231-
$this->assertFalse(isset($data['__name__']));
231+
$this->assertArrayNotHasKey('__name__', $data);
232232
}
233233

234234
public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
@@ -241,7 +241,7 @@ public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet()
241241

242242
$form->setData(array('foobar.png'));
243243
$data = $form->getData();
244-
$this->assertFalse(isset($data['__name__']));
244+
$this->assertArrayNotHasKey('__name__', $data);
245245
}
246246

247247
public function testPrototypeNameOption()

Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed()
444444
))
445445
->createView();
446446

447-
$this->assertFalse(isset($view->vars['type']));
447+
$this->assertArrayNotHasKey('type', $view->vars);
448448
}
449449

450450
public function testDontPassHtml5TypeIfNotHtml5Format()
@@ -455,7 +455,7 @@ public function testDontPassHtml5TypeIfNotHtml5Format()
455455
))
456456
->createView();
457457

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

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

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

471471
public function testDateTypeChoiceErrorsBubbleUp()

Tests/Extension/Core/Type/DateTypeTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ public function testDontPassDatePatternIfText()
678678
))
679679
->createView();
680680

681-
$this->assertFalse(isset($view->vars['date_pattern']));
681+
$this->assertArrayNotHasKey('date_pattern', $view->vars);
682682
}
683683

684684
public function testDatePatternFormatWithQuotedStrings()
@@ -844,7 +844,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed()
844844
))
845845
->createView();
846846

847-
$this->assertFalse(isset($view->vars['type']));
847+
$this->assertArrayNotHasKey('type', $view->vars);
848848
}
849849

850850
public function testDontPassHtml5TypeIfNotHtml5Format()
@@ -855,7 +855,7 @@ public function testDontPassHtml5TypeIfNotHtml5Format()
855855
))
856856
->createView();
857857

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

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

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

871871
public function provideCompoundWidgets()

Tests/Extension/Core/Type/TimeTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ public function testDontPassHtml5TypeIfHtml5NotAllowed()
536536
));
537537

538538
$view = $form->createView();
539-
$this->assertFalse(isset($view->vars['type']));
539+
$this->assertArrayNotHasKey('type', $view->vars);
540540
}
541541

542542
public function testPassDefaultPlaceholderToViewIfNotRequired()

Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function testCsrfProtectionByDefaultIfRootAndCompound()
7777
))
7878
->createView();
7979

80-
$this->assertTrue(isset($view['csrf']));
80+
$this->assertArrayHasKey('csrf', $view);
8181
}
8282

8383
public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot()
@@ -94,7 +94,7 @@ public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot()
9494
->get('form')
9595
->createView();
9696

97-
$this->assertFalse(isset($view['csrf']));
97+
$this->assertArrayNotHasKey('csrf', $view);
9898
}
9999

100100
public function testNoCsrfProtectionByDefaultIfRootButNotCompound()
@@ -106,7 +106,7 @@ public function testNoCsrfProtectionByDefaultIfRootButNotCompound()
106106
))
107107
->createView();
108108

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

112112
public function testCsrfProtectionCanBeDisabled()
@@ -119,7 +119,7 @@ public function testCsrfProtectionCanBeDisabled()
119119
))
120120
->createView();
121121

122-
$this->assertFalse(isset($view['csrf']));
122+
$this->assertArrayNotHasKey('csrf', $view);
123123
}
124124

125125
public function testGenerateCsrfToken()
@@ -362,7 +362,7 @@ public function testNoCsrfProtectionOnPrototype()
362362
->createView()
363363
->vars['prototype'];
364364

365-
$this->assertFalse(isset($prototypeView['csrf']));
365+
$this->assertArrayNotHasKey('csrf', $prototypeView);
366366
$this->assertCount(1, $prototypeView);
367367
}
368368

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)