Skip to content

Commit

Permalink
minor #32969 Use assertContainsEquals when needed (jderusse)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

Use assertContainsEquals when needed

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32844
| License       | MIT
| Doc PR        | NA

This PR replaces deprecated paramèter `$checkForObjectIdentity` of methods `assertContains` by the dedicated method `assertContainsEquals`

Commits
-------

f842e59 Use assert assertContainsEquals when needed
  • Loading branch information
nicolas-grekas committed Aug 6, 2019
2 parents 08573a1 + f842e59 commit 443e923
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
Expand Up @@ -85,7 +85,7 @@ public function testExtensionConfigurationIsTrackedByDefault()
$pass = new MergeExtensionConfigurationPass();
$pass->process($container);

$this->assertContains(new FileResource(__FILE__), $container->getResources(), '', false, false);
$this->assertContainsEquals(new FileResource(__FILE__), $container->getResources());
}

public function testOverriddenEnvsAreMerged()
Expand Down
Expand Up @@ -32,11 +32,11 @@ public function testCountriesAreSelectable()
->createView()->vars['choices'];

// Don't check objects for identity
$this->assertContains(new ChoiceView('DE', 'DE', 'Germany'), $choices, '', false, false);
$this->assertContains(new ChoiceView('GB', 'GB', 'United Kingdom'), $choices, '', false, false);
$this->assertContains(new ChoiceView('US', 'US', 'United States'), $choices, '', false, false);
$this->assertContains(new ChoiceView('FR', 'FR', 'France'), $choices, '', false, false);
$this->assertContains(new ChoiceView('MY', 'MY', 'Malaysia'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('DE', 'DE', 'Germany'), $choices);
$this->assertContainsEquals(new ChoiceView('GB', 'GB', 'United Kingdom'), $choices);
$this->assertContainsEquals(new ChoiceView('US', 'US', 'United States'), $choices);
$this->assertContainsEquals(new ChoiceView('FR', 'FR', 'France'), $choices);
$this->assertContainsEquals(new ChoiceView('MY', 'MY', 'Malaysia'), $choices);
}

public function testUnknownCountryIsNotIncluded()
Expand Down
Expand Up @@ -31,9 +31,9 @@ public function testCurrenciesAreSelectable()
$choices = $this->factory->create(static::TESTED_TYPE)
->createView()->vars['choices'];

$this->assertContains(new ChoiceView('EUR', 'EUR', 'Euro'), $choices, '', false, false);
$this->assertContains(new ChoiceView('USD', 'USD', 'US Dollar'), $choices, '', false, false);
$this->assertContains(new ChoiceView('SIT', 'SIT', 'Slovenian Tolar'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('EUR', 'EUR', 'Euro'), $choices);
$this->assertContainsEquals(new ChoiceView('USD', 'USD', 'US Dollar'), $choices);
$this->assertContainsEquals(new ChoiceView('SIT', 'SIT', 'Slovenian Tolar'), $choices);
}

public function testSubmitNull($expected = null, $norm = null, $view = null)
Expand Down
Expand Up @@ -31,19 +31,19 @@ public function testCountriesAreSelectable()
$choices = $this->factory->create(static::TESTED_TYPE)
->createView()->vars['choices'];

$this->assertContains(new ChoiceView('en', 'en', 'English'), $choices, '', false, false);
$this->assertContains(new ChoiceView('en_GB', 'en_GB', 'British English'), $choices, '', false, false);
$this->assertContains(new ChoiceView('en_US', 'en_US', 'American English'), $choices, '', false, false);
$this->assertContains(new ChoiceView('fr', 'fr', 'French'), $choices, '', false, false);
$this->assertContains(new ChoiceView('my', 'my', 'Burmese'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('en', 'en', 'English'), $choices);
$this->assertContainsEquals(new ChoiceView('en_GB', 'en_GB', 'British English'), $choices);
$this->assertContainsEquals(new ChoiceView('en_US', 'en_US', 'American English'), $choices);
$this->assertContainsEquals(new ChoiceView('fr', 'fr', 'French'), $choices);
$this->assertContainsEquals(new ChoiceView('my', 'my', 'Burmese'), $choices);
}

public function testMultipleLanguagesIsNotIncluded()
{
$choices = $this->factory->create(static::TESTED_TYPE, 'language')
->createView()->vars['choices'];

$this->assertNotContains(new ChoiceView('mul', 'mul', 'Mehrsprachig'), $choices, '', false, false);
$this->assertNotContainsEquals(new ChoiceView('mul', 'mul', 'Mehrsprachig'), $choices);
}

public function testSubmitNull($expected = null, $norm = null, $view = null)
Expand Down
Expand Up @@ -31,9 +31,9 @@ public function testLocalesAreSelectable()
$choices = $this->factory->create(static::TESTED_TYPE)
->createView()->vars['choices'];

$this->assertContains(new ChoiceView('en', 'en', 'English'), $choices, '', false, false);
$this->assertContains(new ChoiceView('en_GB', 'en_GB', 'English (United Kingdom)'), $choices, '', false, false);
$this->assertContains(new ChoiceView('zh_Hant_HK', 'zh_Hant_HK', 'Chinese (Traditional, Hong Kong SAR China)'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('en', 'en', 'English'), $choices);
$this->assertContainsEquals(new ChoiceView('en_GB', 'en_GB', 'English (United Kingdom)'), $choices);
$this->assertContainsEquals(new ChoiceView('zh_Hant_HK', 'zh_Hant_HK', 'Chinese (Traditional, Hong Kong SAR China)'), $choices);
}

public function testSubmitNull($expected = null, $norm = null, $view = null)
Expand Down
Expand Up @@ -23,10 +23,10 @@ public function testTimezonesAreSelectable()
->createView()->vars['choices'];

$this->assertArrayHasKey('Africa', $choices);
$this->assertContains(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Kinshasa'), $choices['Africa'], '', false, false);
$this->assertContainsEquals(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Kinshasa'), $choices['Africa']);

$this->assertArrayHasKey('America', $choices);
$this->assertContains(new ChoiceView('America/New_York', 'America/New_York', 'New York'), $choices['America'], '', false, false);
$this->assertContainsEquals(new ChoiceView('America/New_York', 'America/New_York', 'New York'), $choices['America']);
}

public function testSubmitNull($expected = null, $norm = null, $view = null)
Expand Down Expand Up @@ -70,6 +70,6 @@ public function testFilterByRegions()
$choices = $this->factory->create(static::TESTED_TYPE, null, ['regions' => \DateTimeZone::EUROPE])
->createView()->vars['choices'];

$this->assertContains(new ChoiceView('Europe/Amsterdam', 'Europe/Amsterdam', 'Amsterdam'), $choices, '', false, false);
$this->assertContainsEquals(new ChoiceView('Europe/Amsterdam', 'Europe/Amsterdam', 'Amsterdam'), $choices);
}
}
Expand Up @@ -208,8 +208,8 @@ public function testAuthenticateWithPreservingRoleSwitchUserRole()

$this->assertInstanceOf('Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken', $authToken);
$this->assertSame($user, $authToken->getUser());
$this->assertContains(new Role('ROLE_FOO'), $authToken->getRoles(), '', false, false);
$this->assertContains($switchUserRole, $authToken->getRoles(), '', false, false);
$this->assertContainsEquals(new Role('ROLE_FOO'), $authToken->getRoles());
$this->assertContainsEquals($switchUserRole, $authToken->getRoles());
$this->assertEquals('foo', $authToken->getCredentials());
$this->assertEquals(['foo' => 'bar'], $authToken->getAttributes(), '->authenticate() copies token attributes');
}
Expand Down

0 comments on commit 443e923

Please sign in to comment.