From d5426f0a7609d97f5fa52a77be79a1280bddd460 Mon Sep 17 00:00:00 2001 From: Joseph Bielawski Date: Tue, 11 Dec 2012 09:37:25 +0100 Subject: [PATCH] [Form] Add tests to prove that label is not rendered when is marked as false --- .../Form/Tests/AbstractDivLayoutTest.php | 17 +++++++++++++++++ .../Form/Tests/AbstractTableLayoutTest.php | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php index 576d7890da..ac9b18b065 100644 --- a/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php @@ -526,6 +526,23 @@ abstract class AbstractDivLayoutTest extends AbstractLayoutTest ); } + public function testLabelIsNotRenderedWhenSetToFalse() + { + $form = $this->factory->createNamed('name', 'text', null, array( + 'label' => false + )); + $html = $this->renderRow($form->createView()); + + $this->assertMatchesXpath($html, +'/div + [ + ./input[@id="name"] + ] + [count(//label)=0] +' + ); + } + /** * @dataProvider themeBlockInheritanceProvider */ diff --git a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php index c21c712c5c..efa957fb0b 100644 --- a/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php @@ -39,6 +39,25 @@ abstract class AbstractTableLayoutTest extends AbstractLayoutTest ); } + public function testLabelIsNotRenderedWhenSetToFalse() + { + $form = $this->factory->createNamed('name', 'text', null, array( + 'label' => false + )); + $html = $this->renderRow($form->createView()); + + $this->assertMatchesXpath($html, +'/tr + [ + ./td + [count(//label)=0] + /following-sibling::td + [./input[@id="name"]] + ] +' + ); + } + public function testRepeatedRow() { $form = $this->factory->createNamed('name', 'repeated');