From c0eed67aa87c2d25f62b5637365d3c6e0b79d4fe Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 24 Jul 2019 21:38:05 +0200 Subject: [PATCH] relax some assertions to make tests forward compatible --- .../Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php | 6 ++++-- .../Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php | 4 ---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php index 7a806d76cd7f..83cbbd1426c7 100644 --- a/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php +++ b/src/Symfony/Bridge/Doctrine/Tests/Form/Type/EntityTypeTest.php @@ -848,7 +848,8 @@ public function testPreferredChoices() ]); $this->assertEquals([3 => new ChoiceView($entity3, '3', 'Baz'), 2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['preferred_choices']); - $this->assertEquals([1 => new ChoiceView($entity1, '1', 'Foo')], $field->createView()->vars['choices']); + $this->assertArrayHasKey(1, $field->createView()->vars['choices']); + $this->assertEquals(new ChoiceView($entity1, '1', 'Foo'), $field->createView()->vars['choices'][1]); } public function testOverrideChoicesWithPreferredChoices() @@ -868,7 +869,8 @@ public function testOverrideChoicesWithPreferredChoices() ]); $this->assertEquals([3 => new ChoiceView($entity3, '3', 'Baz')], $field->createView()->vars['preferred_choices']); - $this->assertEquals([2 => new ChoiceView($entity2, '2', 'Bar')], $field->createView()->vars['choices']); + $this->assertArrayHasKey(2, $field->createView()->vars['choices']); + $this->assertEquals(new ChoiceView($entity2, '2', 'Bar'), $field->createView()->vars['choices'][2]); } public function testDisallowChoicesThatAreNotIncludedChoicesSingleIdentifier() diff --git a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php index 183cd820c3d0..5763345afd8b 100644 --- a/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Bridge/Twig/Tests/Extension/AbstractBootstrap3LayoutTest.php @@ -404,7 +404,6 @@ public function testSingleChoiceWithPreferred() /following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"] /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] ] - [count(./option)=3] ' ); } @@ -427,7 +426,6 @@ public function testSingleChoiceWithPreferredAndNoSeparator() ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] ] - [count(./option)=2] ' ); } @@ -451,7 +449,6 @@ public function testSingleChoiceWithPreferredAndBlankSeparator() /following-sibling::option[@disabled="disabled"][not(@selected)][.=""] /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] ] - [count(./option)=3] ' ); } @@ -468,7 +465,6 @@ public function testChoiceWithOnlyPreferred() $this->assertWidgetMatchesXpath($form->createView(), ['attr' => ['class' => 'my&class']], '/select [@class="my&class form-control"] - [count(./option)=2] ' ); }