8000 [Form] Make tested features configurable · symfony/symfony@c584b3c · GitHub
[go: up one dir, main page]

Skip to content

Commit c584b3c

Browse files
[Form] Make tested features configurable
1 parent d1be9d0 commit c584b3c

File tree

6 files changed

+33
-4
lines changed

6 files changed

+33
-4
lines changed

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionBootstrap3LayoutTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
2727
*/
2828
protected $extension;
2929

30+
protected $testableFeatures = array(
31+
'choice_attr',
32+
);
33+
3034
protected function setUp()
3135
{
3236
parent::setUp();

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionDivLayoutTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
2828
*/
2929
protected $extension;
3030

31+
protected $testableFeatures = array(
32+
'choice_attr',
33+
);
34+
3135
protected function setUp()
3236
{
3337
parent::setUp();

src/Symfony/Bridge/Twig/Tests/Extension/FormExtensionTableLayoutTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
2727
*/
2828
protected $extension;
2929

30+
protected $testableFeatures = array(
31+
'choice_attr',
32+
);
33+
3034
protected function setUp()
3135
{
3236
parent::setUp();

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperDivLayoutTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class FormHelperDivLayoutTest extends AbstractDivLayoutTest
2727
*/
2828
protected $engine;
2929

30+
protected $testableFeatures = array(
31+
'choice_attr',
32+
);
33+
3034
protected function getExtensions()
3135
{
3236
// should be moved to the Form component once absolute file paths are supported

src/Symfony/Bundle/FrameworkBundle/Tests/Templating/Helper/FormHelperTableLayoutTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ class FormHelperTableLayoutTest extends AbstractTableLayoutTest
2727
*/
2828
protected $engine;
2929

30+
protected $testableFeatures = array(
31+
'choice_attr',
32+
);
33+
3034
protected function getExtensions()
3135
{
3236
// should be moved to the Form component once absolute file paths are supported

src/Symfony/Component/Form/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)
0