Skip to content

Commit 7723706

Browse files
[Form] Make tested features configurable
1 parent 7eb710b commit 7723706

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

Tests/AbstractLayoutTest.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase
1919
{
2020
protected $csrfTokenManager;
21+
protected $testableFeatures = array();
2122

2223
protected function setUp()
2324
{
@@ -521,13 +522,15 @@ public function testSingleChoiceAttributes()
521522
'expanded' => false,
522523
));
523524

525+
$classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : '';
526+
524527
$this->assertWidgetMatchesXpath($form->createView(), array(),
525528
'/select
526529
[@name="name"]
527530
[not(@required)]
528531
[
529532
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
530-
/following-sibling::option[@value="&b"][@class="foo&bar"][not(@selected)][.="[trans]Choice&B[/trans]"]
533+
/following-sibling::option[@value="&b"]'.$classPart.'[not(@selected)][.="[trans]Choice&B[/trans]"]
531534
]
532535
[count(./option)=2]
533536
'
@@ -804,14 +807,16 @@ public function testMultipleChoiceAttributes()
804807
'expanded' => false,
805808
));
806809

810+
$classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : '';
811+
807812
$this->assertWidgetMatchesXpath($form->createView(), array(),
808813
'/select
809814
[@name="name[]"]
810815
[@required="required"]
811816
[@multiple="multiple"]
812817
[
813818
./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
814-
/following-sibling::option[@value="&b"][@class="foo&bar"][not(@selected)][.="[trans]Choice&B[/trans]"]
819+
/following-sibling::option[@value="&b"]'.$classPart.'[not(@selected)][.="[trans]Choice&B[/trans]"]
815820
]
816821
[count(./option)=2]
817822
'
@@ -893,12 +898,14 @@ public function testSingleChoiceExpandedAttributes()
893898
'expanded' => true,
894899
));
895900

901+
$classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : '';
902+
896903
$this->assertWidgetMatchesXpath($form->createView(), array(),
897904
'/div
898905
[
899906
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
900907
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
901-
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][@class="foo&bar"][not(@checked)]
908+
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"]'.$classPart.'[not(@checked)]
902909
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
903910
/following-sibling::input[@type="hidden"][@id="name__token"]
904911
]
@@ -989,12 +996,14 @@ public function testMultipleChoiceExpandedAttributes()
989996
'required' => true,
990997
));
991998

999+
$classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : '';
1000+
9921001
$this->assertWidgetMatchesXpath($form->createView(), array(),
9931002
'/div
9941003
[
9951004
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
9961005
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
997-
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][@class="foo&bar"][not(@checked)][not(@required)]
1006+
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"]'.$classPart.'[not(@checked)][not(@required)]
9981007
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
9991008
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
10001009
/following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"]

0 commit comments

Comments
 (0)