diff --git a/fixtures/Entity/DummyWithThrowableSetter.php b/fixtures/Entity/DummyWithThrowableSetter.php new file mode 100644 index 000000000..77e662861 --- /dev/null +++ b/fixtures/Entity/DummyWithThrowableSetter.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Nelmio\Alice\Entity; + +class DummyWithThrowableSetter +{ + private $val = null; + + /** + * @param $val + */ + public function setVal($val) + { + if (!empty($this->val)) { + throw new \LogicException('val is already initialised, cant be set again'); + } + + $this->val = $val; + } +} \ No newline at end of file diff --git a/tests/Loader/LoaderIntegrationTest.php b/tests/Loader/LoaderIntegrationTest.php index f9b93c0e5..20c7ca824 100644 --- a/tests/Loader/LoaderIntegrationTest.php +++ b/tests/Loader/LoaderIntegrationTest.php @@ -1842,6 +1842,35 @@ public function provideFixturesToHydrate() public function provideFixturesToGenerate() { + + yield '[construct] with reference to object with throwable setter' => [ + [ + FixtureEntity\DummyWithThrowableSetter::class => [ + 'another_dummy' => [ + 'val' => 1 + ] + ], + FixtureEntity\DummyWithConstructorParam::class => [ + 'dummy' => [ + '__construct' => [ + '@another_dummy' + ] + ] + ] + ], + [ + 'parameters' => [], + 'objects' => [ + 'another_dummy' => $anotherDummy1 = StdClassFactory::create([ + 'val' => 1, + ]), + 'dummy' => $dummy1 = StdClassFactory::create([ + 'val' => $anotherDummy1, + ]), + ] + ] + ]; + yield 'empty instance' => [ [ stdClass::class => [