mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 00:34:24 +00:00
57 lines
1.6 KiB
PHP
57 lines
1.6 KiB
PHP
<?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 Search\Utils;
|
|
|
|
use Chill\MainBundle\Search\Utils\ExtractPhonenumberFromPattern;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
|
/**
|
|
* @internal
|
|
* @coversNothing
|
|
*/
|
|
final class ExtractPhonenumberFromPatternTest extends KernelTestCase
|
|
{
|
|
public function provideData()
|
|
{
|
|
yield ['Diallo', 0, [], 'Diallo', 'no phonenumber'];
|
|
|
|
yield ['Diallo 15/06/2021', 0, [], 'Diallo 15/06/2021', 'no phonenumber and a date'];
|
|
|
|
yield ['Diallo 0486 123 456', 1, ['+32486123456'], 'Diallo', 'a phonenumber and a name'];
|
|
|
|
yield ['Diallo 123 456', 1, ['123456'], 'Diallo', 'a number and a name, without leadiing 0'];
|
|
|
|
yield ['123 456', 1, ['123456'], '', 'only phonenumber'];
|
|
|
|
yield ['0123 456', 1, ['+32123456'], '', 'only phonenumber with a leading 0'];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provideData
|
|
*
|
|
* @param mixed $subject
|
|
* @param mixed $expectedCount
|
|
* @param mixed $expected
|
|
* @param mixed $filteredSubject
|
|
* @param mixed $msg
|
|
*/
|
|
public function testExtract($subject, $expectedCount, $expected, $filteredSubject, $msg)
|
|
{
|
|
$extractor = new ExtractPhonenumberFromPattern();
|
|
$result = $extractor->extractPhonenumber($subject);
|
|
|
|
$this->assertCount($expectedCount, $result->getFound());
|
|
$this->assertEquals($filteredSubject, $result->getFilteredSubject());
|
|
$this->assertEquals($expected, $result->getFound());
|
|
}
|
|
}
|