8000 [Form] Make tested features configurable by nicolas-grekas · Pull Request #14225 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Make tested features configurable #14225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Form] Make tested features configurable
  • Loading branch information
nicolas-grekas committed Apr 5, 2015
commit c584b3c69786e0563eeb53f86afc2d929f4a0904
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class FormExtensionBootstrap3LayoutTest extends AbstractBootstrap3LayoutTest
*/
protected $extension;

protected $testableFeatures = array(
'choice_attr',
);

protected function setUp()
{
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ class FormExtensionDivLayoutTest extends AbstractDivLayoutTest
*/
protected $extension;

protected $testableFeatures = array(
'choice_attr',
);

protected function setUp()
{
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class FormExtensionTableLayoutTest extends AbstractTableLayoutTest
*/
protected $extension;

protected $testableFeatures = array(
'choice_attr',
);

protected function setUp()
{
parent::setUp();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase
{
protected $csrfTokenManager;
protected $testableFeatures = array();

protected function setUp()
{
Expand Down Expand Up @@ -521,13 +522,15 @@ public function testSingleChoiceAttributes()
'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]
'
Expand Down Expand Up @@ -804,14 +807,16 @@ public function testMultipleChoiceAttributes()
'expanded' => false,
));

$classPart = in_array('choice_attr', $this->testableFeatures) ? '[@class="foo&bar"]' : '';

$this->assertWidgetMatchesXpath($form->createView(), array(),
'/select
[@name="name[]"]
[@required="required"]
[@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]
'
Expand Down Expand Up @@ -893,12 +898,14 @@ public function testSingleChoiceExpandedAttributes()
'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"]
]
Expand Down Expand Up @@ -989,12 +996,14 @@ public function testMultipleChoiceExpandedAttributes()
'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]"]
Expand Down
0