From c584b3c69786e0563eeb53f86afc2d929f4a0904 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sun, 5 Apr 2015 23:37:27 +0200 Subject: [PATCH] [Form] Make tested features configurable --- .../FormExtensionBootstrap3LayoutTest.php | 4 ++++ .../Extension/FormExtensionDivLayoutTest.php | 4 ++++ .../Extension/FormExtensionTableLayoutTest.php | 4 ++++ .../Helper/FormHelperDivLayoutTest.php | 4 ++++ .../Helper/FormHelperTableLayoutTest.php | 4 ++++ .../Component/Form/Tests/AbstractLayoutTest.php | 17 +++++++++++++---- 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php index 4e05eff492..8e76552697 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php @@ -27,6 +27,10 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest */ protected $extension; + protected $testableFeatures = array( + 'choice_attr', + ); + protected function setUp() { parent::setUp(); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php index 334abd7092..b72e25412d 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php @@ -28,6 +28,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest */ protected $extension; + protected $testableFeatures = array( + 'choice_attr', + ); + protected function setUp() { parent::setUp(); diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php index b2e21a3961..f8f3ddf3e5 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php @@ -27,6 +27,10 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest */ protected $extension; + protected $testableFeatures = array( + 'choice_attr', + ); + protected function setUp() { parent::setUp(); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php index 8135adcb98..52d91ec127 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php @@ -27,6 +27,10 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest */ protected $engine; + protected $testableFeatures = array( + 'choice_attr', + ); + protected function getExtensions() { // should be moved to the Form component once absolute file paths are supported diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php index 2014575f8c..4a5c025c6d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php @@ -27,6 +27,10 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest */ protected $engine; + protected $testableFeatures = array( + 'choice_attr', + ); + protected function getExtensions() { // should be moved to the Form component once absolute file paths are supported diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index e346b95885..76365a552c 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -18,6 +18,7 @@ use Symfony\Component\Form\Extension\Csrf\CsrfExtension; abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase { protected $csrfTokenManager; + protected $testableFeatures = array(); protected function setUp() { @@ -521,13 +522,15 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg 'expanded' => false, )); + $classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : ''; + $this->assertWidgetMatchesXpath($form->createView(), array(), '/select [@name="name"] [not(@required)] [ ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][@class="foo&bar"][not(@selected)][.="[trans]Choice&B[/trans]"] + /following-sibling::option[@value="&b"]'.$classPart.'[not(@selected)][.="[trans]Choice&B[/trans]"] ] [count(./option)=2] ' @@ -804,6 +807,8 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg 'expanded' => false, )); + $classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : ''; + $this->assertWidgetMatchesXpath($form->createView(), array(), '/select [@name="name[]"] @@ -811,7 +816,7 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg [@multiple="multiple"] [ ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][@class="foo&bar"][not(@selected)][.="[trans]Choice&B[/trans]"] + /following-sibling::option[@value="&b"]'.$classPart.'[not(@selected)][.="[trans]Choice&B[/trans]"] ] [count(./option)=2] ' @@ -893,12 +898,14 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg 'expanded' => true, )); + $classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : ''; + $this->assertWidgetMatchesXpath($form->createView(), array(), '/div [ ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] - /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][@class="foo&bar"][not(@checked)] + /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"]'.$classPart.'[not(@checked)] /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] /following-sibling::input[@type="hidden"][@id="name__token"] ] @@ -989,12 +996,14 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg 'required' => true, )); + $classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : ''; + $this->assertWidgetMatchesXpath($form->createView(), array(), '/div [ ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)] /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] - /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][@class="foo&bar"][not(@checked)][not(@required)] + /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"]'.$classPart.'[not(@checked)][not(@required)] /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)] /following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"]