File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
tests/Integration/ORM/EntityRelationship Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -150,7 +150,10 @@ public function create(array|callable $attributes = []): array
150
150
$ lastFactory = \array_pop ($ factories );
151
151
// @phpstan-ignore method.notFound (phpstan does not understand that we only have persistent factories here)
152
152
$ factories = \array_map (static fn (Factory $ f ) => $ f ->notRootFactory (), $ factories );
153
- $ factories [] = $ lastFactory ;
153
+
154
+ if ($ lastFactory !== null ) {
155
+ $ factories [] = $ lastFactory ;
156
+ }
154
157
}
155
158
156
159
return \array_map (static fn (Factory $ f ) => $ f ->create ($ attributes ), $ factories );
Original file line number Diff line number Diff line change @@ -751,6 +751,19 @@ static function() {
751
751
static ::categoryFactory ()::assert ()->count (2 );
752
752
}
753
753
754
+ /** @test */
755
+ #[Test]
756
+ #[DataProvider('provideCascadeRelationshipsCombinations ' )]
757
+ #[UsingRelationships(Contact::class, ['category ' ])]
758
+ public function call_many_with_zero_do_nothing (): void
759
+ {
760
+ static ::contactFactory ()
761
+ ->many (0 )
762
+ ->create ();
763
+
764
+ static ::contactFactory ()::assert ()->count (0 );
765
+ }
766
+
754
767
/** @return PersistentObjectFactory<Contact> */
755
768
protected static function contactFactoryWithoutCategory (): PersistentObjectFactory
756
769
{
You can’t perform that action at this time.
0 commit comments