Skip to content

Commit

Permalink
Merge pull request #305 from tshelburne/304-quoting
Browse files Browse the repository at this point in the history
added check in reference builder to enable quoting references
  • Loading branch information
tshelburne committed Jan 19, 2016
2 parents c8cb341 + 80c2dca commit d097338
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Nelmio/Alice/Instances/Processor/Methods/Reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function setObjects(Collection $objects)
*/
public function canProcess(ProcessableInterface $processable)
{
return is_string($processable->getValue()) && $processable->valueMatches('{^(?:(?<multi>\d+)x )?@(?<reference>[a-z0-9_.*-]+)(?<sequence>\{(?P<from>\d+)\.\.(?P<to>\d+)\})?(?:\->(?<property>[a-z0-9_-]+))?$}i');
return is_string($processable->getValue()) && $processable->valueMatches('{^\'?(?:(?<multi>\d+)x )?@(?<reference>[a-z0-9_.*-]+)(?<sequence>\{(?P<from>\d+)\.\.(?P<to>\d+)\})?(?:\->(?<property>[a-z0-9_-]+))?\'?$}i');
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/Nelmio/Alice/Fixtures/LoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,26 @@ public function testLoadParsesReferences()
$this->assertEquals('alice', current($group->getMembers())->username);
}

public function testLoadParsesReferencesInQuotes()
{
$res = $this->loadData([
self::USER => [
'user1' => [
'username' => 'alice',
],
],
self::GROUP => [
'a' => [
'members' => ['\'@user1\'']
],
],
]);
$group = $res['a'];

$this->assertInstanceOf(self::USER, current($group->getMembers()));
$this->assertEquals('alice', current($group->getMembers())->username);
}

public function testLoadParsesPropertyReferences()
{
$res = $this->loadData([
Expand Down

0 comments on commit d097338

Please sign in to comment.