Fixed broken tests

This commit is contained in:
Nyholm 2018-02-13 23:04:19 +01:00 committed by Nicolas Grekas
parent cf4e95662e
commit 14e2282513
4 changed files with 205 additions and 239 deletions

View File

@ -217,7 +217,7 @@
{{ widget|raw }}
<label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %}>
{{ label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
{{- label is not same as(false) ? (translation_domain is same as(false) ? label : label|trans({}, translation_domain)) -}}
{{- form_errors(form) -}}
</label>
{%- endif -%}

View File

@ -23,7 +23,7 @@
"symfony/asset": "~2.8|~3.0|~4.0",
"symfony/dependency-injection": "~2.8|~3.0|~4.0",
"symfony/finder": "~2.8|~3.0|~4.0",
"symfony/form": "~3.4|~4.0",
"symfony/form": "^3.4.5|^4.0.5",
"symfony/http-foundation": "^3.3.11|~4.0",
"symfony/http-kernel": "~3.2|~4.0",
"symfony/polyfill-intl-icu": "~1.0",
@ -41,7 +41,7 @@
"symfony/workflow": "~3.3|~4.0"
},
"conflict": {
"symfony/form": "<3.4",
"symfony/form": "<3.4.5",
"symfony/console": "<3.4"
},
"suggest": {

View File

@ -53,7 +53,7 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4
$this->assertMatchesXpath($html,
'/legend
[@class="col-form-label col-sm-2 col-form-legend required"]
[@class="col-form-label col-sm-2 col-form-label required"]
[.="[trans]Name[/trans]"]
'
);
@ -144,7 +144,7 @@ abstract class AbstractBootstrap4HorizontalLayoutTest extends AbstractBootstrap4
$this->assertMatchesXpath($html,
'/legend
[@class="col-sm-2 col-form-legend required"]
[@class="col-sm-2 col-form-label required"]
[.="[trans]Custom label[/trans]"]
'
);

View File

@ -53,7 +53,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertMatchesXpath($html,
'/legend
[@class="col-form-legend required"]
[@class="col-form-label required"]
[.="[trans]Name[/trans]"]
'
);
@ -144,7 +144,7 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertMatchesXpath($html,
'/legend
[@class="col-form-legend required"]
[@class="col-form-label required"]
[.="[trans]Custom label[/trans]"]
'
);
@ -183,13 +183,11 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="form-check"]
[
./label
[.=" [trans]Name[/trans]"]
[@class="form-check-label required"]
[
./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class form-check-input"][@checked="checked"][@value="1"]
]
/following-sibling::label
[.="[trans]Name[/trans]"]
[@class="form-check-label required"]
]
'
);
@ -233,21 +231,17 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]Choice&A[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
[.="[trans]Choice&A[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&B[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
[.="[trans]Choice&B[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -262,12 +256,10 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="form-check"]
[
./label
[.=" [trans]Name[/trans]"]
[
./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class form-check-input"][not(@checked)]
]
/following-sibling::label
[.="[trans]Name[/trans]"]
]
'
);
@ -282,12 +274,10 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="form-check"]
[
./label
[.=" [trans]Name[/trans]"]
[
./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class form-check-input"][@value="foo&bar"]
]
/following-sibling::label
[.="[trans]Name[/trans]"]
]
'
);
@ -306,21 +296,17 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]Choice&A[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
[.="[trans]Choice&A[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&B[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
[.="[trans]Choice&B[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -342,19 +328,15 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
]
/following-sibling::div
[@class="form-check"]
[
./label
[
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -382,29 +364,23 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]label.&a[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
[.="[trans]label.&a[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]label.&c[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_2"][@value="&c"][not(@checked)]
]
/following-sibling::label
[.="[trans]label.&c[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -428,19 +404,15 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
]
/following-sibling::div
[@class="form-check"]
[
./label
[
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -462,21 +434,17 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" Choice&A"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
[.="Choice&A"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" Choice&B"]
[
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
[.="Choice&B"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -498,21 +466,17 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]Choice&A[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
[.="[trans]Choice&A[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&B[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)][@class="foo&bar form-check-input"]
]
/following-sibling::label
[.="[trans]Choice&B[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -535,30 +499,24 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]Test&Me[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)]
]
/following-sibling::label
[.="[trans]Test&Me[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&A[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
]
/following-sibling::label
[.="[trans]Choice&A[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&B[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
]
/following-sibling::label
[.="[trans]Choice&B[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -582,30 +540,24 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" Placeholder&Not&Translated"]
[
./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)]
]
/following-sibling::label
[.="Placeholder&Not&Translated"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" Choice&A"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
]
/following-sibling::label
[.="Choice&A"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" Choice&B"]
[
./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
]
/following-sibling::label
[.="Choice&B"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -626,21 +578,17 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]Choice&A[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
]
/following-sibling::label
[.="[trans]Choice&A[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&B[/trans]"]
[
./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
]
/following-sibling::label
[.="[trans]Choice&B[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -662,30 +610,24 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]Choice&A[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
]
/following-sibling::label
[.="[trans]Choice&A[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&B[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
]
/following-sibling::label
[.="[trans]Choice&B[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&C[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
]
/following-sibling::label
[.="[trans]Choice&C[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -707,19 +649,15 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
]
/following-sibling::div
[@class="form-check"]
[
./label
[
./input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -747,29 +685,23 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]label.&a[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
[.="[trans]label.&a[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[
./input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]label.&c[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_2"][@value="&c"][not(@checked)]
]
/following-sibling::label
[.="[trans]label.&c[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -793,19 +725,15 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@value="&a"][@checked]
]
/following-sibling::label
]
/following-sibling::div
[@class="form-check"]
[
./label
[
./input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)]
]
/following-sibling::label
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -828,30 +756,24 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" Choice&A"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
]
/following-sibling::label
[.="Choice&A"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" Choice&B"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
]
/following-sibling::label
[.="Choice&B"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" Choice&C"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
]
/following-sibling::label
[.="Choice&C"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -874,30 +796,24 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[
./div
[@class="form-check"]
[
./label
[.=" [trans]Choice&A[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
]
/following-sibling::label
[.="[trans]Choice&A[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&B[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)][@class="foo&bar form-check-input"]
]
/following-sibling::label
[.="[trans]Choice&B[/trans]"]
]
/following-sibling::div
[@class="form-check"]
[
./label
[.=" [trans]Choice&C[/trans]"]
[
./input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
]
/following-sibling::label
[.="[trans]Choice&C[/trans]"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
@ -912,9 +828,6 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="form-check"]
[
./label
[@class="form-check-label required"]
[
./input
[@id="my&id"]
@ -923,7 +836,8 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[@class="my&class form-check-input"]
[@checked="checked"]
[@value="1"]
]
/following-sibling::label
[@class="form-check-label required"]
]
'
);
@ -936,9 +850,6 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="form-check"]
[
./label
[@class="form-check-label required"]
[
./input
[@id="my&id"]
@ -946,7 +857,8 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[@name="name"]
[@class="my&class form-check-input"]
[not(@checked)]
]
/following-sibling::label
[@class="form-check-label required"]
]
'
);
@ -961,9 +873,6 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="form-check"]
[
./label
[@class="form-check-label required"]
[
./input
[@id="my&id"]
@ -971,7 +880,9 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
[@name="name"]
[@class="my&class form-check-input"]
[@value="foo&bar"]
]
/following-sibling::label
[@class="form-check-label required"]
[@for="my&id"]
]
'
);
@ -996,6 +907,61 @@ abstract class AbstractBootstrap4LayoutTest extends AbstractBootstrap3LayoutTest
$this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class form-control-file')),
'/input
[@type="file"]
'
);
}
public function testMoney()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\MoneyType', 1234.56, array(
'currency' => 'EUR',
));
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="input-group"]
[
./div
[@class="input-group-prepend"]
[
./span
[@class="input-group-text"]
[contains(.., "")]
]
/following-sibling::input
[@id="my&id"]
[@type="text"]
[@name="name"]
[@class="my&class form-control"]
[@value="1234.56"]
]
'
);
}
public function testPercent()
{
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\PercentType', 0.1);
$this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')),
'/div
[@class="input-group"]
[
./input
[@id="my&id"]
[@type="text"]
[@name="name"]
[@class="my&class form-control"]
[@value="10"]
/following-sibling::div
[@class="input-group-append"]
[
./span
[@class="input-group-text"]
[contains(.., "%")]
]
]
'
);
}