Skip to content

Commit e2715b7

Browse files
committed
replace PHPUnit annotations with attributes
1 parent 5326362 commit e2715b7

17 files changed

+121
-230
lines changed

Tests/CountriesEnvVarTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,27 @@
1111

1212
namespace Symfony\Component\Intl\Tests;
1313

14+
use PHPUnit\Framework\Attributes\Group;
1415
use PHPUnit\Framework\TestCase;
1516
use Symfony\Component\Intl\Countries;
1617

17-
/**
18-
* @group intl-data
19-
* @group intl-data-isolate
20-
*/
18+
#[Group('intl-data')]
19+
#[Group('intl-data-isolate')]
2120
class CountriesEnvVarTest extends TestCase
2221
{
23-
public function testWhenEnvVarNotSet(): void
22+
public function testWhenEnvVarNotSet()
2423
{
2524
$this->assertFalse(Countries::exists('XK'));
2625
}
2726

28-
public function testWhenEnvVarSetFalse(): void
27+
public function testWhenEnvVarSetFalse()
2928
{
3029
putenv('SYMFONY_INTL_WITH_USER_ASSIGNED=false');
3130

3231
$this->assertFalse(Countries::exists('XK'));
3332
}
3433

35-
public function testWhenEnvVarSetTrue(): void
34+
public function testWhenEnvVarSetTrue()
3635
{
3736
putenv('SYMFONY_INTL_WITH_USER_ASSIGNED=true');
3837

Tests/CountriesTest.php

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111

1212
namespace Symfony\Component\Intl\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\Group;
16+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1417
use Symfony\Component\Intl\Countries;
1518
use Symfony\Component\Intl\Exception\MissingResourceException;
1619
use Symfony\Component\Intl\Util\IntlTestHelper;
1720

18-
/**
19-
* @group intl-data
20-
*/
21+
#[Group('intl-data')]
2122
class CountriesTest extends ResourceBundleTestCase
2223
{
2324
// The below arrays document the state of the ICU data bundled with this package.
@@ -796,9 +797,7 @@ public function testGetCountryCodes()
796797
$this->assertSame(self::COUNTRIES, Countries::getCountryCodes());
797798
}
798799

799-
/**
800-
* @dataProvider provideLocales
801-
*/
800+
#[DataProvider('provideLocales')]
802801
public function testGetNames($displayLocale)
803802
{
804803
if ('en' !== $displayLocale) {
@@ -821,9 +820,7 @@ public function testGetNamesDefaultLocale()
821820
$this->assertSame(Countries::getNames('de_AT'), Countries::getNames());
822821
}
823822

824-
/**
825-
* @dataProvider provideLocaleAliases
826-
*/
823+
#[DataProvider('provideLocaleAliases')]
827824
public function testGetNamesSupportsAliases($alias, $ofLocale)
828825
{
829826
if ('en' !== $ofLocale) {
@@ -836,9 +833,7 @@ public function testGetNamesSupportsAliases($alias, $ofLocale)
836833
$this->assertEquals(Countries::getNames($ofLocale), Countries::getNames($alias));
837834
}
838835

839-
/**
840-
* @dataProvider provideLocales
841-
*/
836+
#[DataProvider('provideLocales')]
842837
public function testGetName($displayLocale)
843838
{
844839
if ('en' !== $displayLocale) {
@@ -852,9 +847,7 @@ public function testGetName($displayLocale)
852847
}
853848
}
854849

855-
/**
856-
* @requires extension intl
857-
*/
850+
#[RequiresPhpExtension('intl')]
858851
public function testLocaleAliasesAreLoaded()
859852
{
860853
\Locale::setDefault('zh_TW');
@@ -911,9 +904,7 @@ public function testAlpha3CodeExists()
911904
$this->assertFalse(Countries::alpha3CodeExists('ZZZ'));
912905
}
913906

914-
/**
915-
* @dataProvider provideLocales
916-
*/
907+
#[DataProvider('provideLocales')]
917908
public function testGetAlpha3Name($displayLocale)
918909
{
919910
if ('en' !== $displayLocale) {
@@ -935,9 +926,7 @@ public function testGetAlpha3NameWithInvalidCountryCode()
935926
Countries::getAlpha3Name('ZZZ');
936927
}
937928

938-
/**
939-
* @dataProvider provideLocales
940-
*/
929+
#[DataProvider('provideLocales')]
941930
public function testGetAlpha3Names($displayLocale)
942931
{
943932
if ('en' !== $displayLocale) {

Tests/CountriesWithUserAssignedTest.php

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111

1212
namespace Symfony\Component\Intl\Tests;
1313

14+
use PHPUnit\Framework\Attributes\DataProvider;
15+
use PHPUnit\Framework\Attributes\Group;
16+
use PHPUnit\Framework\Attributes\RequiresPhpExtension;
1417
use Symfony\Component\Intl\Countries;
1518
use Symfony\Component\Intl\Exception\MissingResourceException;
1619
use Symfony\Component\Intl\Util\IntlTestHelper;
1720

18-
/**
19-
* @group intl-data
20-
*/
21+
#[Group('intl-data')]
2122
class CountriesWithUserAssignedTest extends ResourceBundleTestCase
2223
{
2324
/*
@@ -795,7 +796,7 @@ public static function tearDownAfterClass(): void
795796
Countries::withUserAssigned(false);
796797
}
797798

798-
public function testAllGettersGenerateTheSameDataSetCount(): void
799+
public function testAllGettersGenerateTheSameDataSetCount()
799800
{
800801
$expected = \count(self::COUNTRIES_WITH_USER_ASSIGNED);
801802
$alpha2Count = \count(Countries::getCountryCodes());
@@ -810,15 +811,13 @@ public function testAllGettersGenerateTheSameDataSetCount(): void
810811
$this->assertEquals($expected, $numericCodesCount, 'Numeric codes count does not match');
811812
}
812813

813-
public function testGetCountryCodes(): void
814+
public function testGetCountryCodes()
814815
{
815816
$this->assertSame(self::COUNTRIES_WITH_USER_ASSIGNED, Countries::getCountryCodes());
816817
}
817818

818-
/**
819-
* @dataProvider provideLocales
820-
*/
821-
public function testGetNames($displayLocale): void
819+
#[DataProvider('provideLocales')]
820+
public function testGetNames($displayLocale)
822821
{
823822
if ('en' !== $displayLocale) {
824823
IntlTestHelper::requireFullIntl($this);
@@ -833,10 +832,9 @@ public function testGetNames($displayLocale): void
833832

834833
/**
835834
* This test is for backward compatibility; testGetNames already checks `XK` is included.
836-
*
837-
* @dataProvider provideLocaleAliases
838835
*/
839-
public function testGetNamesSupportsAliases($alias, $ofLocale): void
836+
#[DataProvider('provideLocaleAliases')]
837+
public function testGetNamesSupportsAliases($alias, $ofLocale)
840838
{
841839
if ('en' !== $ofLocale) {
842840
IntlTestHelper::requireFullIntl($this);
@@ -850,9 +848,8 @@ public function testGetNamesSupportsAliases($alias, $ofLocale): void
850848

851849
/**
852850
* This test is for backward compatibility; testGetNames already checks `XK` is included.
853-
*
854-
* @dataProvider provideLocales
855851
*/
852+
#[DataProvider('provideLocales')]
856853
public function testGetName($displayLocale)
857854
{
858855
if ('en' !== $displayLocale) {
@@ -866,9 +863,7 @@ public function testGetName($displayLocale)
866863
}
867864
}
868865

869-
/**
870-
* @requires extension intl
871-
*/
866+
#[RequiresPhpExtension('intl')]
872867
public function testLocaleAliasesAreLoaded()
873868
{
874869
\Locale::setDefault('zh_TW');
@@ -884,40 +879,40 @@ public function testLocaleAliasesAreLoaded()
884879
$this->assertNotSame($countryNameZh, $countryNameZhTw, 'zh_TW does not fall back to zh');
885880
}
886881

887-
public function testGetNameWithInvalidCountryCode(): void
882+
public function testGetNameWithInvalidCountryCode()
888883
{
889884
$this->expectException(MissingResourceException::class);
890885
Countries::getName('PAL'); // PSE is commonly confused with PAL
891886
}
892887

893-
public function testExists(): void
888+
public function testExists()
894889
{
895890
$this->assertTrue(Countries::exists('NL'));
896891
$this->assertTrue(Countries::exists('XK'));
897892
$this->assertFalse(Countries::exists('ZZ'));
898893
}
899894

900-
public function testGetAlpha3Codes(): void
895+
public function testGetAlpha3Codes()
901896
{
902897
$this->assertSame(self::ALPHA2_TO_ALPHA3_WITH_USER_ASSIGNED, Countries::getAlpha3Codes());
903898
}
904899

905-
public function testGetAlpha3Code(): void
900+
public function testGetAlpha3Code()
906901
{
907902
foreach (self::COUNTRIES_WITH_USER_ASSIGNED as $country) {
908903
$this->assertSame(self::ALPHA2_TO_ALPHA3_WITH_USER_ASSIGNED[$country], Countries::getAlpha3Code($country));
909904
}
910905
}
911906

912-
public function testGetAlpha2Code(): void
907+
public function testGetAlpha2Code()
913908
{
914909
foreach (self::COUNTRIES_WITH_USER_ASSIGNED as $alpha2Code) {
915910
$alpha3Code = self::ALPHA2_TO_ALPHA3_WITH_USER_ASSIGNED[$alpha2Code];
916911
$this->assertSame($alpha2Code, Countries::getAlpha2Code($alpha3Code));
917912
}
918913
}
919914

920-
public function testAlpha3CodeExists(): void
915+
public function testAlpha3CodeExists()
921916
{
922917
$this->assertTrue(Countries::alpha3CodeExists('ALB'));
923918
$this->assertTrue(Countries::alpha3CodeExists('DEU'));
@@ -927,10 +922,8 @@ public function testAlpha3CodeExists(): void
927922
$this->assertFalse(Countries::alpha3CodeExists('ZZZ'));
928923
}
929924

930-
/**
931-
* @dataProvider provideLocales
932-
*/
933-
public function testGetAlpha3Name($displayLocale): void
925+
#[DataProvider('provideLocales')]
926+
public function testGetAlpha3Name($displayLocale)
934927
{
935928
if ('en' !== $displayLocale) {
936929
IntlTestHelper::requireFullIntl($this);
@@ -944,16 +937,14 @@ public function testGetAlpha3Name($displayLocale): void
944937
}
945938
}
946939

947-
public function testGetAlpha3NameWithInvalidCountryCode(): void
940+
public function testGetAlpha3NameWithInvalidCountryCode()
948941
{
949942
$this->expectException(MissingResourceException::class);
950943

951944
Countries::getAlpha3Name('ZZZ');
952945
}
953946

954-
/**
955-
* @dataProvider provideLocales
956-
*/
947+
#[DataProvider('provideLocales')]
957948
public function testGetAlpha3Names($displayLocale)
958949
{
959950
if ('en' !== $displayLocale) {
@@ -969,19 +960,19 @@ public function testGetAlpha3Names($displayLocale)
969960
$this->assertEqualsCanonicalizing(array_values($alpha2Names), array_values($names));
970961
}
971962

972-
public function testGetNumericCodes(): void
963+
public function testGetNumericCodes()
973964
{
974965
$this->assertSame(self::ALPHA2_TO_NUMERIC_WITH_USER_ASSIGNED, Countries::getNumericCodes());
975966
}
976967

977-
public function testGetNumericCode(): void
968+
public function testGetNumericCode()
978969
{
979970
foreach (self::COUNTRIES_WITH_USER_ASSIGNED as $country) {
980971
$this->assertSame(self::ALPHA2_TO_NUMERIC_WITH_USER_ASSIGNED[$country], Countries::getNumericCode($country));
981972
}
982973
}
983974

984-
public function testNumericCodeExists(): void
975+
public function testNumericCodeExists()
985976
{
986977
$this->assertTrue(Countries::numericCodeExists('250'));
987978
$this->assertTrue(Countries::numericCodeExists('008'));
@@ -990,7 +981,7 @@ public function testNumericCodeExists(): void
990981
$this->assertFalse(Countries::numericCodeExists('667'));
991982
}
992983

993-
public function testGetAlpha2FromNumeric(): void
984+
public function testGetAlpha2FromNumeric()
994985
{
995986
$alpha2Lookup = array_flip(self::ALPHA2_TO_NUMERIC_WITH_USER_ASSIGNED);
996987

@@ -999,7 +990,7 @@ public function testGetAlpha2FromNumeric(): void
999990
}
1000991
}
1001992

1002-
public function testNumericCodesDoNotContainDenyListItems(): void
993+
public function testNumericCodesDoNotContainDenyListItems()
1003994
{
1004995
$numericCodes = Countries::getNumericCodes();
1005996

0 commit comments

Comments
 (0)