From d780fdff10854d93010b4a027fab92b747b42586 Mon Sep 17 00:00:00 2001 From: Fabien Lucas Date: Sat, 7 Apr 2018 11:33:52 +0200 Subject: [PATCH] Fix faker regexp when we want to generate SR_LATN names (#906) --- .../Alice/Instances/Processor/Methods/Faker.php | 2 +- tests/Nelmio/Alice/Fixtures/LoaderTest.php | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Nelmio/Alice/Instances/Processor/Methods/Faker.php b/src/Nelmio/Alice/Instances/Processor/Methods/Faker.php index 629597a18..5007ec6ba 100644 --- a/src/Nelmio/Alice/Instances/Processor/Methods/Faker.php +++ b/src/Nelmio/Alice/Instances/Processor/Methods/Faker.php @@ -120,7 +120,7 @@ public function canProcess(ProcessableInterface $processable) */ public function process(ProcessableInterface $processable, array $variables) { - $fakerRegex = '<(?:(?[a-z]+(?:_[a-z]+)?):)?(?[a-z0-9_]+?)?\((?(?:[^)]*|\)(?!>))*)\)>'; + $fakerRegex = '<(?:(?[a-z]+(?:_[a-z]+)?(?:_[a-z]+)?):)?(?[a-z0-9_]+?)?\((?(?:[^)]*|\)(?!>))*)\)>'; if ($processable->valueMatches('#^'.$fakerRegex.'$#i')) { return $this->replacePlaceholder($processable->getMatches(), $variables); } diff --git a/tests/Nelmio/Alice/Fixtures/LoaderTest.php b/tests/Nelmio/Alice/Fixtures/LoaderTest.php index 57240d39f..56d616603 100644 --- a/tests/Nelmio/Alice/Fixtures/LoaderTest.php +++ b/tests/Nelmio/Alice/Fixtures/LoaderTest.php @@ -2130,6 +2130,23 @@ public function testDuplicateFixturesId() ); } + /** + * @issue https://github.com/nelmio/alice/issues/906 + */ + public function testFakerWithLatinLocale() + { + $res = $this->loadData([ + self::USER => [ + 'user0' => [ + 'family_name' => '', + ], + ], + ]); + + $this->assertNotEquals('', $res['user0']->family_name); + $this->assertNotEmpty($res['user0']->family_name); + } + /** * Always return the same structure, see the first sample. */