Skip to content

Commit

Permalink
minor #34245 Fix WeekType tests (fancyweb)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

Fix WeekType tests

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

`WeekToArrayTransformer::reverseTransform()` requires an integer + `testWeekChoices()` widget arg was forgotten.

Commits
-------

906b82e Fix WeekType tests
  • Loading branch information
Tobion committed Nov 5, 2019
2 parents a307733 + 906b82e commit ba1ba97
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2771,11 +2771,11 @@ public function testWeekChoices()
{
$this->requiresFeatureSet(404);

$data = ['year' => date('Y'), 'week' => 1];
$data = ['year' => (int) date('Y'), 'week' => 1];

$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\WeekType', $data, [
'input' => 'array',
'required' => false,
'widget' => 'choice',
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
Expand Down
12 changes: 10 additions & 2 deletions src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2768,6 +2768,8 @@ public function submitFormNoValidateProvider()

public function testWeekSingleText()
{
$this->requiresFeatureSet(404);

$form = $this->factory->createNamed('holidays', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '1970-W01', [
'input' => 'string',
'widget' => 'single_text',
Expand All @@ -2785,6 +2787,8 @@ public function testWeekSingleText()

public function testWeekSingleTextNoHtml5()
{
$this->requiresFeatureSet(404);

$form = $this->factory->createNamed('holidays', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '1970-W01', [
'input' => 'string',
'widget' => 'single_text',
Expand All @@ -2803,11 +2807,13 @@ public function testWeekSingleTextNoHtml5()

public function testWeekChoices()
{
$data = ['year' => date('Y'), 'week' => 1];
$this->requiresFeatureSet(404);

$data = ['year' => (int) date('Y'), 'week' => 1];

$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\WeekType', $data, [
'input' => 'array',
'required' => false,
'widget' => 'choice',
]);

$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
Expand All @@ -2827,6 +2833,8 @@ public function testWeekChoices()

public function testWeekText()
{
$this->requiresFeatureSet(404);

$form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\WeekType', '2000-W01', [
'input' => 'string',
'widget' => 'text',
Expand Down

0 comments on commit ba1ba97

Please sign in to comment.