Skip to content

Commit

Permalink
Fix faker regexp when we want to generate SR_LATN names (#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
tifabien authored and theofidry committed Apr 7, 2018
1 parent bc0137b commit d780fdf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nelmio/Alice/Instances/Processor/Methods/Faker.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function canProcess(ProcessableInterface $processable)
*/
public function process(ProcessableInterface $processable, array $variables)
{
$fakerRegex = '<(?:(?<locale>[a-z]+(?:_[a-z]+)?):)?(?<name>[a-z0-9_]+?)?\((?<args>(?:[^)]*|\)(?!>))*)\)>';
$fakerRegex = '<(?:(?<locale>[a-z]+(?:_[a-z]+)?(?:_[a-z]+)?):)?(?<name>[a-z0-9_]+?)?\((?<args>(?:[^)]*|\)(?!>))*)\)>';
if ($processable->valueMatches('#^'.$fakerRegex.'$#i')) {
return $this->replacePlaceholder($processable->getMatches(), $variables);
}
Expand Down
17 changes: 17 additions & 0 deletions tests/Nelmio/Alice/Fixtures/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => '<sr_Latn_RS:lastName()>',
],
],
]);

$this->assertNotEquals('<sr_Latn_RS:lastName()>', $res['user0']->family_name);
$this->assertNotEmpty($res['user0']->family_name);
}

/**
* Always return the same structure, see the first sample.
*/
Expand Down

0 comments on commit d780fdf

Please sign in to comment.