Skip to content

Commit e96d00b

Browse files
committed
Correct and add tests for new html5 step attribute
1 parent 0cc23a6 commit e96d00b

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,25 @@ public function testRenderNumberWithHtml5NumberType()
21542154
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
21552155
'/input
21562156
[@type="number"]
2157+
[@step="any"]
2158+
[@name="name"]
2159+
[@class="my&class form-control"]
2160+
[@value="1234.56"]
2161+
'
2162+
);
2163+
}
2164+
2165+
public function testRenderNumberWithHtml5NumberTypeAndStepAttribute()
2166+
{
2167+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [
2168+
'html5' => true,
2169+
'attr' => ['step' => '0.1'],
2170+
]);
2171+
2172+
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
2173+
'/input
2174+
[@type="number"]
2175+
[@step="0.1"]
21572176
[@name="name"]
21582177
[@class="my&class form-control"]
21592178
[@value="1234.56"]

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1877,6 +1877,26 @@ public function testRenderNumberWithHtml5NumberType()
18771877
$this->assertWidgetMatchesXpath($form->createView(), [],
18781878
'/input
18791879
[@type="number"]
1880+
[@step="any"]
1881+
[@name="name"]
1882+
[@value="1234.56"]
1883+
'
1884+
);
1885+
}
1886+
1887+
public function testRenderNumberWithHtml5NumberTypeAndStepAttribute()
1888+
{
1889+
$this->requiresFeatureSet(403);
1890+
1891+
$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\NumberType', 1234.56, [
1892+
'html5' => true,
1893+
'attr' => ['step' => '0.1'],
1894+
]);
1895+
1896+
$this->assertWidgetMatchesXpath($form->createView(), [],
1897+
'/input
1898+
[@type="number"]
1899+
[@step="0.1"]
18801900
[@name="name"]
18811901
[@value="1234.56"]
18821902
'

0 commit comments

Comments
 (0)