Skip to content

Commit bb25ed9

Browse files
committed
PHPUnit 10 attributes
1 parent fe4f2ab commit bb25ed9

File tree

1 file changed

+19
-48
lines changed

1 file changed

+19
-48
lines changed

tests/PhoneNumberTest.php

Lines changed: 19 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
use Brick\PhoneNumber\PhoneNumber;
88
use Brick\PhoneNumber\PhoneNumberException;
9+
use Brick\PhoneNumber\PhoneNumberFormat;
910
use Brick\PhoneNumber\PhoneNumberParseException;
1011
use Brick\PhoneNumber\PhoneNumberType;
11-
use Brick\PhoneNumber\PhoneNumberFormat;
12-
12+
use PHPUnit\Framework\Attributes\DataProvider;
1313
use PHPUnit\Framework\TestCase;
1414

1515
/**
@@ -55,9 +55,7 @@ class PhoneNumberTest extends TestCase
5555
private const UNIVERSAL_PREMIUM_RATE = '+979123456789';
5656
private const UNKNOWN_COUNTRY_CODE_NO_RAW_INPUT = '+212345';
5757

58-
/**
59-
* @dataProvider providerGetExampleNumber
60-
*/
58+
#[DataProvider('providerGetExampleNumber')]
6159
public function testGetExampleNumber(string $regionCode, string $callingCode, ?PhoneNumberType $numberType = null) : void
6260
{
6361
if ($numberType === null) {
@@ -94,9 +92,7 @@ public function testGetExampleNumberThrowsExceptionForInvalidRegionCode() : void
9492
PhoneNumber::getExampleNumber('ZZ');
9593
}
9694

97-
/**
98-
* @dataProvider providerGetNationalNumber
99-
*/
95+
#[DataProvider('providerGetNationalNumber')]
10096
public function testGetNationalNumber(string $expectedNationalNumber, string $phoneNumber) : void
10197
{
10298
self::assertSame($expectedNationalNumber, PhoneNumber::parse($phoneNumber)->getNationalNumber());
@@ -112,9 +108,7 @@ public static function providerGetNationalNumber() : array
112108
];
113109
}
114110

115-
/**
116-
* @dataProvider providerParseNationalNumber
117-
*/
111+
#[DataProvider('providerParseNationalNumber')]
118112
public function testParseNationalNumber(string $expectedNumber, string $numberToParse, string $regionCode) : void
119113
{
120114
self::assertSame($expectedNumber, (string) PhoneNumber::parse($numberToParse, $regionCode));
@@ -153,9 +147,7 @@ public static function providerParseNationalNumber() : array
153147
];
154148
}
155149

156-
/**
157-
* @dataProvider providerGetRegionCode
158-
*/
150+
#[DataProvider('providerGetRegionCode')]
159151
public function testGetRegionCode(?string $expectedRegion, string $phoneNumber) : void
160152
{
161153
self::assertSame($expectedRegion, PhoneNumber::parse($phoneNumber)->getRegionCode());
@@ -171,9 +163,7 @@ public static function providerGetRegionCode() : array
171163
];
172164
}
173165

174-
/**
175-
* @dataProvider providerGetNumberType
176-
*/
166+
#[DataProvider('providerGetNumberType')]
177167
public function testGetNumberType(PhoneNumberType $numberType, string $phoneNumber) : void
178168
{
179169
self::assertSame($numberType, PhoneNumber::parse($phoneNumber)->getNumberType());
@@ -227,35 +217,27 @@ public static function providerGetNumberType() : array
227217
];
228218
}
229219

230-
/**
231-
* @dataProvider providerValidNumbers
232-
* @dataProvider providerPossibleButNotValidNumbers
233-
*/
220+
#[DataProvider('providerValidNumbers')]
221+
#[DataProvider('providerPossibleButNotValidNumbers')]
234222
public function testIsPossibleNumber(string $phoneNumber) : void
235223
{
236224
self::assertTrue(PhoneNumber::parse($phoneNumber)->isPossibleNumber());
237225
}
238226

239-
/**
240-
* @dataProvider providerNotPossibleNumbers
241-
*/
227+
#[DataProvider('providerNotPossibleNumbers')]
242228
public function testIsNotPossibleNumber(string $phoneNumber) : void
243229
{
244230
self::assertFalse(PhoneNumber::parse($phoneNumber)->isPossibleNumber());
245231
}
246232

247-
/**
248-
* @dataProvider providerValidNumbers
249-
*/
233+
#[DataProvider('providerValidNumbers')]
250234
public function testIsValidNumber(string $phoneNumber) : void
251235
{
252236
self::assertTrue(PhoneNumber::parse($phoneNumber)->isValidNumber());
253237
}
254238

255-
/**
256-
* @dataProvider providerNotPossibleNumbers
257-
* @dataProvider providerPossibleButNotValidNumbers
258-
*/
239+
#[DataProvider('providerNotPossibleNumbers')]
240+
#[DataProvider('providerPossibleButNotValidNumbers')]
259241
public function testIsNotValidNumber(string $phoneNumber) : void
260242
{
261243
self::assertFalse(PhoneNumber::parse($phoneNumber)->isValidNumber());
@@ -293,9 +275,7 @@ public static function providerNotPossibleNumbers() : array
293275
];
294276
}
295277

296-
/**
297-
* @dataProvider providerParseException
298-
*/
278+
#[DataProvider('providerParseException')]
299279
public function testParseException(string $phoneNumber, ?string $regionCode = null) : void
300280
{
301281
$this->expectException(PhoneNumberParseException::class);
@@ -344,9 +324,7 @@ public static function providerParseException() : array
344324
];
345325
}
346326

347-
/**
348-
* @dataProvider providerFormatNumber
349-
*/
327+
#[DataProvider('providerFormatNumber')]
350328
public function testFormatNumber(string $expected, string $phoneNumber, PhoneNumberFormat $numberFormat) : void
351329
{
352330
self::assertSame($expected, PhoneNumber::parse($phoneNumber)->format($numberFormat));
@@ -446,9 +424,7 @@ public static function providerFormatNumber() : array
446424
];
447425
}
448426

449-
/**
450-
* @dataProvider providerFormatForCallingFrom
451-
*/
427+
#[DataProvider('providerFormatForCallingFrom')]
452428
public function testFormatForCallingFrom(string $phoneNumber, string $countryCode, string $expected) : void
453429
{
454430
self::assertSame($expected, PhoneNumber::parse($phoneNumber)->formatForCallingFrom($countryCode));
@@ -474,9 +450,7 @@ public static function providerFormatForCallingFrom() : array
474450
];
475451
}
476452

477-
/**
478-
* @dataProvider providerGetGeographicalAreaCode
479-
*/
453+
#[DataProvider('providerGetGeographicalAreaCode')]
480454
public function testGetGeographicalAreaCode(string $phoneNumber, string $areaCode) : void
481455
{
482456
self::assertSame($areaCode, PhoneNumber::parse($phoneNumber)->getGeographicalAreaCode());
@@ -496,9 +470,7 @@ public static function providerGetGeographicalAreaCode() : array
496470
];
497471
}
498472

499-
/**
500-
* @dataProvider providerIsEqualTo
501-
*/
473+
#[DataProvider('providerIsEqualTo')]
502474
public function testIsEqualTo(string $phoneNumber1, string $phoneNumber2, bool $isEqual): void
503475
{
504476
$phoneNumber1 = PhoneNumber::parse($phoneNumber1);
@@ -528,10 +500,9 @@ public function testJsonSerializable(): void
528500
* The data provider may provide several possible results, as the results differ depending on the version of the
529501
* underlying phonenumber library.
530502
*
531-
* @dataProvider providerGetDescription
532-
*
533503
* @param (string|null)[] $expected
534504
*/
505+
#[DataProvider('providerGetDescription')]
535506
public function testGetDescription(string $phoneNumber, string $locale, ?string $userRegion, array $expected) : void
536507
{
537508
self::assertContains(PhoneNumber::parse($phoneNumber)->getDescription($locale, $userRegion), $expected);

0 commit comments

Comments
 (0)