alice
alice copied to clipboard
Use dynamic data in circular reference
Hi First of all, thanks for this awesome library.
I have a problem with fixtures using dynamic property value with circular references between objects. I have been written a simple test to demonstrate the problem.
use Nelmio\Alice\Loader\NativeLoader;
use PHPUnit\Framework\TestCase;
class DummyTests extends TestCase
{
public function testCircularReferences()
{
$fixures = [
\stdClass::class => [
'foo' => [
'key' => "@foo1->key",
'value' => "<regexify('/[A-Za-z][A-Za-z0-9_]/')>"
],
'foo1' => [
'key' => "<regexify('/[A-Za-z][A-Za-z0-9_]/')>",
'value' => "@foo->value",
]
],
];
$fixturesLoader = new NativeLoader();
$objects = $fixturesLoader->loadData($fixures)->getObjects();
$this->assertEquals($objects['foo']->key, $objects['foo1']->key);
$this->assertEquals($objects['foo']->value, $objects['foo1']->value);
}
}
The test result is
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'Yw'
+'i0'
Alice version v3.4.1. In my opinion we should not regenerate dynamic property values if it is already defined.