mirror of
https://github.com/symfony/ux-translator.git
synced 2026-03-24 00:12:19 +01:00
64 lines
1.7 KiB
PHP
64 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace Symfony\UX\Translator\Tests\MessageParameters;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\UX\Translator\MessageParameters\Extractor\MessageParametersExtractor;
|
|
|
|
class MessageParametersExtractorTest extends TestCase
|
|
{
|
|
/**
|
|
* @dataProvider provideExtract
|
|
*/
|
|
public function testExtract(string $message, array $expectedParameters): void
|
|
{
|
|
$messageParametersExtractor = new MessageParametersExtractor();
|
|
|
|
static::assertEquals($messageParametersExtractor->extract($message), $expectedParameters);
|
|
}
|
|
|
|
public function provideExtract()
|
|
{
|
|
yield [
|
|
'Symfony is great!',
|
|
[],
|
|
];
|
|
|
|
yield [
|
|
'Symfony is %what%!',
|
|
['%what%' => ['type' => 'string']],
|
|
];
|
|
|
|
yield [
|
|
'%framework% is %what%!',
|
|
[
|
|
'%framework%' => ['type' => 'string'],
|
|
'%what%' => ['type' => 'string'],
|
|
],
|
|
];
|
|
|
|
yield [
|
|
'%framework% have more than %years% years!',
|
|
[
|
|
'%framework%' => ['type' => 'string'],
|
|
'%years%' => ['type' => 'string'],
|
|
],
|
|
];
|
|
|
|
yield [
|
|
'{0} There are no apples|{1} There is one apple|]1,Inf] There are %count% apples',
|
|
['%count%' => ['type' => 'number']],
|
|
];
|
|
|
|
yield [
|
|
'There is 1 apple|There are %count% apples',
|
|
['%count%' => ['type' => 'number']],
|
|
];
|
|
|
|
yield [
|
|
'You must select at least {{ limit }} choice.|You must select at least {{ limit }} choices.',
|
|
['{{ limit }}' => ['type' => 'string']],
|
|
];
|
|
}
|
|
}
|