Skip to content

Commit

Permalink
Allow usage of dots in the ReferenceRangeNameDenormalizer (#933)
Browse files Browse the repository at this point in the history
Closes #932
  • Loading branch information
tomtomau authored and theofidry committed Jun 17, 2018
1 parent 12d7bce commit 1695963
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final class ReferenceRangeNameDenormalizer implements ChainableFixtureDenormaliz
{
use IsAServiceTrait;

private const REGEX = '/.+\{(?<expression>@(?<name>([A-Za-z0-9-_]+))(?<flag>(\*+))?)\}/';
private const REGEX = '/.+\{(?<expression>@(?<name>([A-Za-z0-9-_\.]+))(?<flag>(\*+))?)\}/';

/**
* @var FlagParserInterface|null
Expand Down
35 changes: 35 additions & 0 deletions tests/Loader/LoaderIntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,41 @@ public function testLoadReferenceRange()
$this->assertSame($objects['user1'], $objects['userdetail_single_user1']->getUser());
}

public function testLoadReferenceRangeWithDotInName()
{
$data = [
User::class => [
'foo.user.{1..3}' => [
'id' => '<uuid()>',
'name' => '<username()>',
],
],
UserDetail::class => [
'foo.user_detail.{@foo.user.*}' => [
'email' => '<email()>',
'user' => '<current()>',
],
],
];

$set = $this->loader->loadData($data);

$objects = $set->getObjects();
$this->assertCount(6, $objects);

$this->assertArrayHasKey('foo.user.1', $objects);
$this->assertArrayHasKey('foo.user.2', $objects);
$this->assertArrayHasKey('foo.user.3',$objects);

$this->assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.1']->getUser());
$this->assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.2']->getUser());
$this->assertInstanceOf(User::class, $objects['foo.user_detail.foo.user.3']->getUser());

$this->assertSame($objects['foo.user.1'], $objects['foo.user_detail.foo.user.1']->getUser());
$this->assertSame($objects['foo.user.2'], $objects['foo.user_detail.foo.user.2']->getUser());
$this->assertSame($objects['foo.user.3'], $objects['foo.user_detail.foo.user.3']->getUser());
}

public function testTemplatesAreKeptBetweenFiles()
{
$expected = new ObjectSet(
Expand Down

0 comments on commit 1695963

Please sign in to comment.