mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 07:26:12 +00:00
34 lines
1.2 KiB
PHP
34 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Search\Utils;
|
|
|
|
use Chill\MainBundle\Search\Utils\ExtractPhonenumberFromPattern;
|
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
|
|
|
class ExtractPhonenumberFromPatternTest extends KernelTestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideData
|
|
*/
|
|
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());
|
|
}
|
|
|
|
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"];
|
|
}
|
|
|
|
}
|