Skip to content

Commit

Permalink
Migrate to PHPUnit 10
Browse files Browse the repository at this point in the history
  • Loading branch information
BenMorel committed Oct 13, 2023
1 parent 218c898 commit 27a798a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/vendor
/composer.lock
/.phpunit.result.cache
/.phpunit.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"giggsey/libphonenumber-for-php": "^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^10.4",
"php-coveralls/php-coveralls": "^2.0",
"vimeo/psalm": "5.15.0"
},
Expand Down
7 changes: 4 additions & 3 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="PhoneNumber tests">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<coverage/>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>
</source>
</phpunit>
61 changes: 14 additions & 47 deletions tests/PhoneNumberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,7 @@ public function testGetExampleNumber(string $regionCode, string $callingCode, ?i
self::assertSame($regionCode, $phoneNumber->getRegionCode());
}

/**
* @return array
*/
public function providerGetExampleNumber() : array
public static function providerGetExampleNumber() : array
{
return [
['US', '1'],
Expand Down Expand Up @@ -112,10 +109,7 @@ public function testGetNationalNumber(string $expectedNationalNumber, string $ph
self::assertSame($expectedNationalNumber, PhoneNumber::parse($phoneNumber)->getNationalNumber());
}

/**
* @return array
*/
public function providerGetNationalNumber() : array
public static function providerGetNationalNumber() : array
{
return [
['6502530000', self::US_NUMBER],
Expand All @@ -137,10 +131,7 @@ public function testParseNationalNumber(string $expectedNumber, string $numberTo
self::assertSame($expectedNumber, (string) PhoneNumber::parse($numberToParse, $regionCode));
}

/**
* @return array
*/
public function providerParseNationalNumber() : array
public static function providerParseNationalNumber() : array
{
return [
// National prefix attached.
Expand Down Expand Up @@ -184,10 +175,7 @@ public function testGetRegionCode(?string $expectedRegion, string $phoneNumber)
self::assertSame($expectedRegion, PhoneNumber::parse($phoneNumber)->getRegionCode());
}

/**
* @return array
*/
public function providerGetRegionCode() : array
public static function providerGetRegionCode() : array
{
return [
['BS', self::BS_NUMBER],
Expand All @@ -208,10 +196,7 @@ public function testGetNumberType(int $numberType, string $phoneNumber) : void
self::assertSame($numberType, PhoneNumber::parse($phoneNumber)->getNumberType());
}

/**
* @return array
*/
public function providerGetNumberType() : array
public static function providerGetNumberType() : array
{
return [
[PhoneNumberType::PREMIUM_RATE, self::US_PREMIUM],
Expand Down Expand Up @@ -301,10 +286,7 @@ public function testIsNotValidNumber(string $phoneNumber) : void
self::assertFalse(PhoneNumber::parse($phoneNumber)->isValidNumber());
}

/**
* @return array
*/
public function providerValidNumbers() : array
public static function providerValidNumbers() : array
{
return [
[self::US_NUMBER],
Expand All @@ -316,10 +298,7 @@ public function providerValidNumbers() : array
];
}

/**
* @return array
*/
public function providerPossibleButNotValidNumbers() : array
public static function providerPossibleButNotValidNumbers() : array
{
return [
[self::US_LOCAL_NUMBER],
Expand All @@ -331,10 +310,7 @@ public function providerPossibleButNotValidNumbers() : array
];
}

/**
* @return array
*/
public function providerNotPossibleNumbers() : array
public static function providerNotPossibleNumbers() : array
{
return [
[self::INTERNATIONAL_TOLL_FREE_TOO_LONG],
Expand All @@ -354,10 +330,7 @@ public function testParseException(string $phoneNumber, ?string $regionCode = nu
PhoneNumber::parse($phoneNumber, $regionCode);
}

/**
* @return array
*/
public function providerParseException() : array
public static function providerParseException() : array
{
return [
// Empty string.
Expand Down Expand Up @@ -411,10 +384,7 @@ public function testFormatNumber(string $expected, string $phoneNumber, int $num
self::assertSame($expected, PhoneNumber::parse($phoneNumber)->format($numberFormat));
}

/**
* @return array
*/
public function providerFormatNumber() : array
public static function providerFormatNumber() : array
{
return [
// US
Expand Down Expand Up @@ -520,10 +490,7 @@ public function testFormatForCallingFrom(string $phoneNumber, string $countryCod
self::assertSame($expected, PhoneNumber::parse($phoneNumber)->formatForCallingFrom($countryCode));
}

/**
* @return array
*/
public function providerFormatForCallingFrom() : array
public static function providerFormatForCallingFrom() : array
{
return [
['+33123456789', 'FR', '01 23 45 67 89'],
Expand Down Expand Up @@ -551,7 +518,7 @@ public function testGetGeographicalAreaCode(string $phoneNumber, string $areaCod
self::assertSame($areaCode, PhoneNumber::parse($phoneNumber)->getGeographicalAreaCode());
}

public function providerGetGeographicalAreaCode() : array
public static function providerGetGeographicalAreaCode() : array
{
return [
['+442079460585', '20'],
Expand All @@ -576,7 +543,7 @@ public function testIsEqualTo(string $phoneNumber1, string $phoneNumber2, bool $
self::assertSame($isEqual, $phoneNumber1->isEqualTo($phoneNumber2));
}

public function providerIsEqualTo(): array
public static function providerIsEqualTo(): array
{
return [
['+442079460585', '+442079460585', true],
Expand Down Expand Up @@ -606,7 +573,7 @@ public function testGetDescription(string $phoneNumber, string $locale, ?string
self::assertContains(PhoneNumber::parse($phoneNumber)->getDescription($locale, $userRegion), $expected);
}

public function providerGetDescription() : array
public static function providerGetDescription() : array
{
return [
['+16509036313', 'EN', null, ['Mountain View, CA']],
Expand Down

0 comments on commit 27a798a

Please sign in to comment.