From 03009e03503bbe2f97cc0e6b505c2a0faef71ca7 Mon Sep 17 00:00:00 2001 From: Benjamin Morel Date: Fri, 1 Sep 2023 22:36:49 +0200 Subject: [PATCH] Fix tests with newer versions of giggsey --- tests/PhoneNumberTest.php | 75 +++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/tests/PhoneNumberTest.php b/tests/PhoneNumberTest.php index ff84259..9b63d56 100644 --- a/tests/PhoneNumberTest.php +++ b/tests/PhoneNumberTest.php @@ -594,49 +594,54 @@ public function testJsonSerializable(): void } /** + * The data provider may provide several possible results, as the results differ depending on the version of the + * underlying phonenumber library. + * * @dataProvider providerGetDescription + * + * @param (string|null)[] $expected */ - public function testGetDescription(string $phoneNumber, string $locale, ?string $userRegion, ?string $expected) : void + public function testGetDescription(string $phoneNumber, string $locale, ?string $userRegion, array $expected) : void { - self::assertSame($expected, PhoneNumber::parse($phoneNumber)->getDescription($locale, $userRegion)); + self::assertContains(PhoneNumber::parse($phoneNumber)->getDescription($locale, $userRegion), $expected); } public function providerGetDescription() : array { return [ - ['+16509036313', 'EN', null, 'Mountain View, CA'], - ['+16509036313', 'EN', 'US', 'Mountain View, CA'], - ['+16509036313', 'EN', 'GB', 'United States'], - ['+16509036313', 'EN', 'FR', 'United States'], - ['+16509036313', 'EN', 'XX', 'United States'], - ['+16509036313', 'FR', null, 'Mountain View, CA'], - ['+16509036313', 'FR', 'US', 'Mountain View, CA'], - ['+16509036313', 'FR', 'GB', 'États-Unis'], - ['+16509036313', 'FR', 'FR', 'États-Unis'], - ['+16509036313', 'FR', 'XX', 'États-Unis'], - - ['+33381251234', 'FR', null, 'Besançon'], - ['+33381251234', 'FR', 'FR', 'Besançon'], - ['+33381251234', 'FR', 'US', 'France'], - ['+33381251234', 'FR', 'XX', 'France'], - ['+33381251234', 'EN', null, 'Besançon'], - ['+33381251234', 'EN', 'FR', 'Besançon'], - ['+33381251234', 'EN', 'US', 'France'], - ['+33381251234', 'EN', 'XX', 'France'], - - ['+33328201234', 'FR', null, 'Dunkerque'], - ['+33328201234', 'FR', 'FR', 'Dunkerque'], - ['+33328201234', 'FR', 'US', 'France'], - ['+33328201234', 'FR', 'XX', 'France'], - ['+33328201234', 'GB', null, 'Dunkirk'], - ['+33328201234', 'XX', null, 'Dunkirk'], - - ['+41229097000', 'FR', null, 'Genève'], - ['+41229097000', 'FR', 'CH', 'Genève'], - ['+41229097000', 'FR', 'US', 'Suisse'], - ['+41229097000', 'XX', null, 'Geneva'], - - ['+37328000000', 'XX', null, null], + ['+16509036313', 'EN', null, ['Mountain View, CA']], + ['+16509036313', 'EN', 'US', ['Mountain View, CA']], + ['+16509036313', 'EN', 'GB', ['United States']], + ['+16509036313', 'EN', 'FR', ['United States']], + ['+16509036313', 'EN', 'XX', ['United States']], + ['+16509036313', 'FR', null, ['Mountain View, CA']], + ['+16509036313', 'FR', 'US', ['Mountain View, CA']], + ['+16509036313', 'FR', 'GB', ['États-Unis']], + ['+16509036313', 'FR', 'FR', ['États-Unis']], + ['+16509036313', 'FR', 'XX', ['États-Unis']], + + ['+33381251234', 'FR', null, ['France', 'Besançon']], + ['+33381251234', 'FR', 'FR', ['France', 'Besançon']], + ['+33381251234', 'FR', 'US', ['France']], + ['+33381251234', 'FR', 'XX', ['France']], + ['+33381251234', 'EN', null, ['France', 'Besançon']], + ['+33381251234', 'EN', 'FR', ['France', 'Besançon']], + ['+33381251234', 'EN', 'US', ['France']], + ['+33381251234', 'EN', 'XX', ['France']], + + ['+33328201234', 'FR', null, ['France', 'Dunkerque']], + ['+33328201234', 'FR', 'FR', ['France', 'Dunkerque']], + ['+33328201234', 'FR', 'US', ['France']], + ['+33328201234', 'FR', 'XX', ['France']], + ['+33328201234', 'GB', null, ['Dunkirk', null]], + ['+33328201234', 'XX', null, ['Dunkirk', null]], + + ['+41229097000', 'FR', null, ['Genève']], + ['+41229097000', 'FR', 'CH', ['Genève']], + ['+41229097000', 'FR', 'US', ['Suisse']], + ['+41229097000', 'XX', null, ['Geneva']], + + ['+37328000000', 'XX', null, [null]], ]; } }