From 80c2dca5d8b4fe53abacb6c374753eaa34b4cac6 Mon Sep 17 00:00:00 2001 From: Tim Shelburne Date: Sat, 16 Jan 2016 06:15:16 -0700 Subject: [PATCH] added check in reference builder to enable quoting references --- .../Instances/Processor/Methods/Reference.php | 2 +- tests/Nelmio/Alice/Fixtures/LoaderTest.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/Nelmio/Alice/Instances/Processor/Methods/Reference.php b/src/Nelmio/Alice/Instances/Processor/Methods/Reference.php index f84b01493..45f328394 100644 --- a/src/Nelmio/Alice/Instances/Processor/Methods/Reference.php +++ b/src/Nelmio/Alice/Instances/Processor/Methods/Reference.php @@ -36,7 +36,7 @@ public function setObjects(Collection $objects) */ public function canProcess(ProcessableInterface $processable) { - return is_string($processable->getValue()) && $processable->valueMatches('{^(?:(?\d+)x )?@(?[a-z0-9_.*-]+)(?\{(?P\d+)\.\.(?P\d+)\})?(?:\->(?[a-z0-9_-]+))?$}i'); + return is_string($processable->getValue()) && $processable->valueMatches('{^\'?(?:(?\d+)x )?@(?[a-z0-9_.*-]+)(?\{(?P\d+)\.\.(?P\d+)\})?(?:\->(?[a-z0-9_-]+))?\'?$}i'); } /** diff --git a/tests/Nelmio/Alice/Fixtures/LoaderTest.php b/tests/Nelmio/Alice/Fixtures/LoaderTest.php index aefb46d04..54c46da7c 100644 --- a/tests/Nelmio/Alice/Fixtures/LoaderTest.php +++ b/tests/Nelmio/Alice/Fixtures/LoaderTest.php @@ -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([