Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d5426f0

Browse files
committed
[Form] Add tests to prove that label is not rendered when is marked as false
1 parent 120547c commit d5426f0

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,23 @@ public function testLabelHasNoId()
526526
);
527527
}
528528

529+
public function testLabelIsNotRenderedWhenSetToFalse()
530+
{
531+
$form = $this->factory->createNamed('name', 'text', null, array(
532+
'label' => false
533+
));
534+
$html = $this->renderRow($form->createView());
535+
536+
$this->assertMatchesXpath($html,
537+
'/div
538+
[
539+
./input[@id="name"]
540+
]
541+
[count(//label)=0]
542+
'
543+
);
544+
}
545+
529546
/**
530547
* @dataProvider themeBlockInheritanceProvider
531548
*/

src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,25 @@ public function testRow()
3939
);
4040
}
4141

42+
public function testLabelIsNotRenderedWhenSetToFalse()
43+
{
44+
$form = $this->factory->createNamed('name', 'text', null, array(
45+
'label' => false
46+
));
47+
$html = $this->renderRow($form->createView());
48+
49+
$this->assertMatchesXpath($html,
50+
'/tr
51+
[
52+
./td
53+
[count(//label)=0]
54+
/following-sibling::td
55+
[./input[@id="name"]]
56+
]
57+
'
58+
);
59+
}
60+
4261
public function testRepeatedRow()
4362
{
4463
$form = $this->factory->createNamed('name', 'repeated');

0 commit comments

Comments
 (0)