Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 475c7a4

Browse files
committed
adapt tests
1 parent b946b11 commit 475c7a4

File tree

8 files changed

+49
-16
lines changed

8 files changed

+49
-16
lines changed

src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -848,7 +848,7 @@ public function testPreferredChoices()
848848
]);
849849

850850
$this->assertEquals([3 => new ChoiceView($entity3, '3', 'Baz'), 2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['preferred_choices']);
851-
$this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo')], $field->createView()->vars['choices']);
851+
$this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo'), 2 => new ChoiceView($entity2, '2', 'Bar'), 3 => new ChoiceView($entity3, '3', 'Baz')], $field->createView()->vars['choices']);
852852
}
853853

854854
public function testOverrideChoicesWithPreferredChoices()
@@ -868,7 +868,7 @@ public function testOverrideChoicesWithPreferredChoices()
868868
]);
869869

870870
$this->assertEquals([3 => new ChoiceView($entity3, '3', 'Baz')], $field->createView()->vars['preferred_choices']);
871-
$this->assertEquals([2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['choices']);
871+
$this->assertEquals([2 => new ChoiceView($entity2, '2', 'Bar'), 3 => new ChoiceView($entity3, '3', 'Baz')], $field->createView()->vars['choices']);
872872
}
873873

874874
public function testDisallowChoicesThatAreNotIncludedChoicesSingleIdentifier()

src/Symfony/Bridge/Doctrine/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"symfony/stopwatch": "^3.4|^4.0|^5.0",
2828
"symfony/config": "^4.2|^5.0",
2929
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
30-
"symfony/form": "^4.3|^5.0",
30+
"symfony/form": "^4.4|^5.0",
3131
"symfony/http-kernel": "^3.4|^4.0|^5.0",
3232
"symfony/messenger": "^4.3|^5.0",
3333
"symfony/property-access": "^3.4|^4.0|^5.0",
@@ -48,7 +48,7 @@
4848
"conflict": {
4949
"phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0",
5050
"symfony/dependency-injection": "<3.4",
51-
"symfony/form": "<4.3",
51+
"symfony/form": "<4.4",
5252
"symfony/messenger": "<4.3"
5353
},
5454
"suggest": {

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,9 @@ public function testSingleChoiceWithPreferred()
524524
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
525525
/following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"]
526526
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
527+
/following-sibling::option[@value="&b"][.="[trans]Choice&B[/trans]"]
527528
]
528-
[count(./option)=3]
529+
[count(./option)=4]
529530
'
530531
);
531532
}
@@ -547,8 +548,9 @@ public function testSingleChoiceWithPreferredAndNoSeparator()
547548
[
548549
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
549550
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
551+
/following-sibling::option[@value="&b"][.="[trans]Choice&B[/trans]"]
550552
]
551-
[count(./option)=2]
553+
[count(./option)=3]
552554
'
553555
);
554556
}
@@ -571,8 +573,9 @@ public function testSingleChoiceWithPreferredAndBlankSeparator()
571573
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
572574
/following-sibling::option[@disabled="disabled"][not(@selected)][.=""]
573575
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
576+
/following-sibling::option[@value="&b"][.="[trans]Choice&B[/trans]"]
574577
]
575-
[count(./option)=3]
578+
[count(./option)=4]
576579
'
577580
);
578581
}
@@ -589,7 +592,7 @@ public function testChoiceWithOnlyPreferred()
589592
$this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']],
590593
'/select
591594
[@class="my&class form-control"]
592-
[count(./option)=2]
595+
[count(./option)=5]
593596
'
594597
);
595598
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"symfony/asset": "^3.4|^4.0|^5.0",
2626
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
2727
"symfony/finder": "^3.4|^4.0|^5.0",
28-
"symfony/form": "^4.3|^5.0",
28+
"symfony/form": "^4.4|^5.0",
2929
"symfony/http-foundation": "^4.3|^5.0",
3030
"symfony/http-kernel": "^3.4|^4.0|^5.0",
3131
"symfony/mime": "^4.3|^5.0",
@@ -46,7 +46,7 @@
4646
},
4747
"conflict": {
4848
"symfony/console": "<3.4",
49-
"symfony/form": "<4.3",
49+
"symfony/form": "<4.4",
5050
"symfony/http-foundation": "<4.3",
5151
"symfony/translation": "<4.2",
5252
"symfony/workflow": "<4.3"

src/Symfony/Component/Form/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
4.4.0
55
-----
66

7+
* preferred choices are repeated in the list of all choices
78
* deprecated using `int` or `float` as data for the `NumberType` when the `input` option is set to `string`
89

910
4.3.0

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -741,8 +741,9 @@ public function testSingleChoiceWithPreferred()
741741
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
742742
/following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"]
743743
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
744+
/following-sibling::option[@value="&b"][.="[trans]Choice&B[/trans]"]
744745
]
745-
[count(./option)=3]
746+
[count(./option)=4]
746747
'
747748
);
748749
}
@@ -763,8 +764,9 @@ public function testSingleChoiceWithPreferredAndNoSeparator()
763764
[
764765
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
765766
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
767+
/following-sibling::option[@value="&b"][.="[trans]Choice&B[/trans]"]
766768
]
767-
[count(./option)=2]
769+
[count(./option)=3]
768770
'
769771
);
770772
}
@@ -786,8 +788,9 @@ public function testSingleChoiceWithPreferredAndBlankSeparator()
786788
./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"]
787789
/following-sibling::option[@disabled="disabled"][not(@selected)][.=""]
788790
/following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"]
791+
/following-sibling::option[@value="&b"][.="[trans]Choice&B[/trans]"]
789792
]
790-
[count(./option)=3]
793+
[count(./option)=4]
791794
'
792795
);
793796
}
@@ -803,7 +806,7 @@ public function testChoiceWithOnlyPreferred()
803806

804807
$this->assertWidgetMatchesXpath($form->createView(), [],
805808
'/select
806-
[count(./option)=2]
809+
[count(./option)=5]
807810
'
808811
);
809812
}

src/Symfony/Component/Form/Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,6 +739,8 @@ private function assertFlatView($view)
739739
$this->assertEquals(new ChoiceListView(
740740
[
741741
0 => new ChoiceView($this->obj1, '0', 'A'),
742+
1 => new ChoiceView($this->obj2, '1', 'B'),
743+
2 => new ChoiceView($this->obj3, '2', 'C'),
742744
3 => new ChoiceView($this->obj4, '3', 'D'),
743745
], [
744746
1 => new ChoiceView($this->obj2, '1', 'B'),
@@ -752,6 +754,8 @@ private function assertFlatViewWithCustomIndices($view)
752754
$this->assertEquals(new ChoiceListView(
753755
[
754756
'w' => new ChoiceView($this->obj1, '0', 'A'),
757+
'x' => new ChoiceView($this->obj2, '1', 'B'),
758+
'y' => new ChoiceView($this->obj3, '2', 'C'),
755759
'z' => new ChoiceView($this->obj4, '3', 'D'),
756760
], [
757761
'x' => new ChoiceView($this->obj2, '1', 'B'),
@@ -765,6 +769,18 @@ private function assertFlatViewWithAttr($view)
765769
$this->assertEquals(new ChoiceListView(
766770
[
767771
0 => new ChoiceView($this->obj1, '0', 'A'),
772+
1 => new ChoiceView(
773+
$this->obj2,
774+
'1',
775+
'B',
776+
['attr1' => 'value1']
777+
),
778+
2 => new ChoiceView(
779+
$this->obj3,
780+
'2',
781+
'C',
782+
['attr2' => 'value2']
783+
),
768784
3 => new ChoiceView($this->obj4, '3', 'D'),
769785
], [
770786
1 => new ChoiceView(
@@ -789,11 +805,17 @@ private function assertGroupedView($view)
789805
[
790806
'Group 1' => new ChoiceGroupView(
791807
'Group 1',
792-
[0 => new ChoiceView($this->obj1, '0', 'A')]
808+
[
809+
0 => new ChoiceView($this->obj1, '0', 'A'),
810+
1 => new ChoiceView($this->obj2, '1', 'B'),
811+
]
793812
),
794813
'Group 2' => new ChoiceGroupView(
795814
'Group 2',
796-
[3 => new ChoiceView($this->obj4, '3', 'D')]
815+
[
816+
2 => new ChoiceView($this->obj3, '2', 'C'),
817+
3 => new ChoiceView($this->obj4, '3', 'D'),
818+
]
797819
),
798820
], [
799821
'Group 1' => new ChoiceGroupView(

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,9 @@ public function testPassPreferredChoicesToView()
17311731

17321732
$this->assertEquals([
17331733
0 => new ChoiceView('a', 'a', 'A'),
1734+
1 => new ChoiceView('b', 'b', 'B'),
17341735
2 => new ChoiceView('c', 'c', 'C'),
1736+
3 => new ChoiceView('d', 'd', 'D'),
17351737
], $view->vars['choices']);
17361738
$this->assertEquals([
17371739
1 => new ChoiceView('b', 'b', 'B'),
@@ -1750,9 +1752,11 @@ public function testPassHierarchicalChoicesToView()
17501752
$this->assertEquals([
17511753
'Symfony' => new ChoiceGroupView('Symfony', [
17521754
0 => new ChoiceView('a', 'a', 'Bernhard'),
1755+
1 => new ChoiceView('b', 'b', 'Fabien'),
17531756
2 => new ChoiceView('c', 'c', 'Kris'),
17541757
]),
17551758
'Doctrine' => new ChoiceGroupView('Doctrine', [
1759+
3 => new ChoiceView('d', 'd', 'Jon'),
17561760
4 => new ChoiceView('e', 'e', 'Roman'),
17571761
]),
17581762
], $view->vars['choices']);

0 commit comments

Comments
 (0)