mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
fix normalization for phonenumber on person when phonenumber is null
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Serializer\Normalizer\PhonenumberNormalizer;
|
||||
use libphonenumber\PhoneNumber;
|
||||
use libphonenumber\PhoneNumberUtil;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Prophecy\Argument;
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @coversNothing
|
||||
*/
|
||||
final class PhonenumberNormalizerTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function dataProviderNormalizePhonenumber()
|
||||
{
|
||||
$phonenumberUtil = PhoneNumberUtil::getInstance();
|
||||
|
||||
yield [$phonenumberUtil->parse('+32486123465'), 'docgen', ['docgen:expects' => PhoneNumber::class], '0486 12 34 65'];
|
||||
|
||||
yield [null, 'docgen', ['docgen:expects' => PhoneNumber::class], ''];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataProviderNormalizePhonenumber
|
||||
*
|
||||
* @param mixed $format
|
||||
* @param mixed $context
|
||||
* @param mixed $expected
|
||||
*/
|
||||
public function testNormalize(?Phonenumber $phonenumber, $format, $context, $expected)
|
||||
{
|
||||
$parameterBag = $this->prophesize(ParameterBagInterface::class);
|
||||
$parameterBag->get(Argument::exact('chill_main'))->willReturn(['phone_helper' => ['default_carrier_code' => 'BE']]);
|
||||
$normalizer = new PhonenumberNormalizer($parameterBag->reveal());
|
||||
|
||||
$this->assertEquals($expected, $normalizer->normalize($phonenumber, $format, $context));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user