zenstruck / browser

A fluent interface for your Symfony functional tests.
MIT License
185 stars 17 forks source link

POST json relations are arrays instead of objects #135

Closed yobud closed 9 months ago

yobud commented 9 months ago

Hi! Thank you for this awesome library,

In the following example, I have an issue trying to send ManyToOne collection, because addresses[0] is an array instead of an object. I can't figure how to assume it's an object regarding the docs :

$this->browser()
    ->actingAs($user)
    ->post('/api/clients', [
        'json' => [
            'name' => 'test create client',
            'addresses' => [
                [
                    'street' => 'test street',
                    'city' => 'test city',
                    'zipCode' => 'test postal code',
                ]
            ],
        ],
    ])
    ->assertStatus(201);

Kind regards

Edit : My bad, my issue is not related to relation denormalization, I have an issue deserializing an array (not shown in example) that I didn't handled as I should have to.