Closed cnizzardini-cmi closed 1 year ago
In CakePHP 4.2 and Fixture Factory 2.4. I am fairly certain you can reproduce this when using persist() to get the entity as well.
persist()
Steps to reproduce
$foo = FooFactory::make(['test' => null])->getEntity(); $foo->test = 'New'; var_dump($foo->getOriginal('test')); // this will output "New"
Expected Result
$foo->getOriginal('test') outputs NULL
$foo->getOriginal('test')
NULL
More Context
This bug is not present with the following setup in the FooFactory class:
FooFactory
protected function setDefaultTemplate(): void { $this->setDefaultData(function (Generator $faker) { return [ 'test' => null, ]; }); }
With this the following code works as expected:
$foo = FooFactory::make()->getEntity(); $foo->test = 'New'; var_dump($foo->getOriginal('test')); // this will output NULL
I hope this is clear.
In CakePHP 4.2 and Fixture Factory 2.4. I am fairly certain you can reproduce this when using
persist()
to get the entity as well.Steps to reproduce
Expected Result
$foo->getOriginal('test')
outputsNULL
More Context
This bug is not present with the following setup in the
FooFactory
class:With this the following code works as expected:
I hope this is clear.