mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
fix cs
This commit is contained in:
@@ -12,30 +12,90 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Tests\Routing\Loader;
|
||||
|
||||
use Chill\MainBundle\Phonenumber\PhonenumberHelper;
|
||||
use Chill\MainBundle\Phonenumber\PhoneNumberHelperInterface;
|
||||
use Psr\Log\NullLogger;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Symfony\Component\Cache\Adapter\ArrayAdapter;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PhonenumberHelperTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider normalizePhonenumbers
|
||||
*/
|
||||
public function testNormalizePhonenumbers(string $defaultCarrierCode, string $phoneNumber, string $expected)
|
||||
public function denormalizePhonenumbers()
|
||||
{
|
||||
$subject = new PhonenumberHelper(
|
||||
new ArrayAdapter(),
|
||||
new ParameterBag([
|
||||
'chill_main.phone_helper' => [
|
||||
'default_carrier_code' => $defaultCarrierCode,
|
||||
],
|
||||
]),
|
||||
new NullLogger()
|
||||
);
|
||||
yield [
|
||||
'BE',
|
||||
'+3281136917',
|
||||
'+3281136917',
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $subject->normalize($phoneNumber));
|
||||
yield [
|
||||
'BE',
|
||||
'+33 6 23 12 45 54',
|
||||
'+33623124554',
|
||||
];
|
||||
}
|
||||
|
||||
public function formatPhonenumbers()
|
||||
{
|
||||
yield [
|
||||
'BE',
|
||||
'+3281136917',
|
||||
'081 13 69 17',
|
||||
];
|
||||
|
||||
yield [
|
||||
'FR',
|
||||
'+33 6 23 12 45 54',
|
||||
'06 23 12 45 54',
|
||||
];
|
||||
|
||||
yield [
|
||||
'FR',
|
||||
'+32 81 13 69 17',
|
||||
'081 13 69 17',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'+33 6 23 12 45 54',
|
||||
'06 23 12 45 54',
|
||||
];
|
||||
}
|
||||
|
||||
public function normalizePhonenumbers()
|
||||
{
|
||||
yield [
|
||||
'BE',
|
||||
'081136917',
|
||||
'+3281136917',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'003281136917',
|
||||
'+3281136917',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'0032478123456',
|
||||
'+32478123456',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'0478123456',
|
||||
'+32478123456',
|
||||
];
|
||||
|
||||
yield [
|
||||
'FR',
|
||||
'0623124554',
|
||||
'+33623124554',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,75 +134,21 @@ final class PhonenumberHelperTest extends KernelTestCase
|
||||
$this->assertEquals($expected, $subject->format($phoneNumber));
|
||||
}
|
||||
|
||||
public function formatPhonenumbers() {
|
||||
yield [
|
||||
'BE',
|
||||
'+3281136917',
|
||||
'081 13 69 17',
|
||||
];
|
||||
/**
|
||||
* @dataProvider normalizePhonenumbers
|
||||
*/
|
||||
public function testNormalizePhonenumbers(string $defaultCarrierCode, string $phoneNumber, string $expected)
|
||||
{
|
||||
$subject = new PhonenumberHelper(
|
||||
new ArrayAdapter(),
|
||||
new ParameterBag([
|
||||
'chill_main.phone_helper' => [
|
||||
'default_carrier_code' => $defaultCarrierCode,
|
||||
],
|
||||
]),
|
||||
new NullLogger()
|
||||
);
|
||||
|
||||
yield [
|
||||
'FR',
|
||||
'+33 6 23 12 45 54',
|
||||
'06 23 12 45 54',
|
||||
];
|
||||
|
||||
yield [
|
||||
'FR',
|
||||
'+32 81 13 69 17',
|
||||
'081 13 69 17',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'+33 6 23 12 45 54',
|
||||
'06 23 12 45 54',
|
||||
];
|
||||
}
|
||||
|
||||
public function normalizePhonenumbers() {
|
||||
yield [
|
||||
'BE',
|
||||
'081136917',
|
||||
'+3281136917',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'003281136917',
|
||||
'+3281136917',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'0032478123456',
|
||||
'+32478123456',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'0478123456',
|
||||
'+32478123456',
|
||||
];
|
||||
|
||||
yield [
|
||||
'FR',
|
||||
'0623124554',
|
||||
'+33623124554',
|
||||
];
|
||||
}
|
||||
|
||||
public function denormalizePhonenumbers() {
|
||||
yield [
|
||||
'BE',
|
||||
'+3281136917',
|
||||
'+3281136917',
|
||||
];
|
||||
|
||||
yield [
|
||||
'BE',
|
||||
'+33 6 23 12 45 54',
|
||||
'+33623124554',
|
||||
];
|
||||
$this->assertEquals($expected, $subject->normalize($phoneNumber));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user