Skip to content

Commit

Permalink
feat: skip readonly properties on entities when generating factories
Browse files Browse the repository at this point in the history
  • Loading branch information
KDederichs committed Jan 29, 2025
1 parent 7961d20 commit 0257544
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Fixture/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load
{
parent::configureContainer($c, $loader);

$path = \sprintf('%s/config/%s.yaml', __DIR__, $this->getEnvironment());
if (file_exists($path)) {
$loader->load($path);
}



$c->loadFromExtension('zenstruck_foundry', [
'orm' => [
'reset' => [
Expand Down
3 changes: 3 additions & 0 deletions tests/Fixture/config/always_force.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
zenstruck_foundry:
instantiator:
always_force_properties: true # always "force set" properties
2 changes: 2 additions & 0 deletions tests/Integration/Maker/MakeFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ public function does_not_initialize_non_settable(): void
*/
public function does_force_initialization_of_non_settable_with_always_force(): void
{
self::bootKernel(['environment' => 'always_force']);

$tester = $this->makeFactoryCommandTester();

$tester->execute(['class' => ObjectWithNonWriteable::class, '--no-persistence' => true]);
Expand Down

0 comments on commit 0257544

Please sign in to comment.