Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.3.2] new()->many(2) creates single instance #811

Open
xdrew opened this issue Feb 10, 2025 · 2 comments
Open

[2.3.2] new()->many(2) creates single instance #811

xdrew opened this issue Feb 10, 2025 · 2 comments

Comments

@xdrew
Copy link

xdrew commented Feb 10, 2025

Hi! After an update from 2.3.1 some my tests began failing. The factory looks like:

final class OrderFactory extends PersistentProxyObjectFactory
{
    public function withProducts($count = 1): self
    {
        return $this->with(['orderProducts' => OrderProductFactory::new()->many($count)]);
    }
}

And calling this code:

        $user = UserFactory::createOne();
        $order = OrderFactory::new()->withUser($user)->withProducts(2)->create();

        $json = $this
            ->browser()
            ->actingAs($user->_real())
            ->get('/api/orders/' . $order->getUuid())
            ->assertStatus(200)
            ->dump()
            ->json();

shows:

...
{
    "orderProducts": [
        {
            "id": 129,
        }
    ],

On 2.3.1 it creates and shows 2. The bug also appears for 2.3.3 version

@nikophil nikophil added bug Something isn't working and removed bug Something isn't working labels Feb 10, 2025
@nikophil
Copy link
Member

Hello @xdrew

I cannot reproduce your problem.

Could you create a reproducer, or create a failing test case in Foundry's testsuite? You'll find a OneToMany in Category::$contact. You can add the test in EntityFactoryRelationshipTestCase

@xdrew
Copy link
Author

xdrew commented Feb 10, 2025

Could you create a reproducer, or create a failing test case in Foundry's testsuite? You'll find a OneToMany in Category::$contact. You can add the test in EntityFactoryRelationshipTestCase

Ok, I'll take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants