Take a ManyToMany relation.
The third request (when you remove the first one) will give you an object instead of an array.
Scenario: Add a DummyCar to the Brand
Given there is a brand and 5 DummyCar
And I send a "PUT" request to "/brands/1" with body:
"""
{"car": ["/dummy_cars/1"]}
"""
And the JSON should be equal to:
"""
{
"@context": "/contexts/Brand",
"@id": "/brands/1",
"@type": "Brand",
"car": [
"/dummy_cars/1"
],
"id": 1
}
"""
Scenario: Add another DummyCar to the Brand
And I send a "PUT" request to "/brands/1" with body:
"""
{"car": ["/dummy_cars/1", "/dummy_cars/2"]}
"""
And the JSON should be equal to:
"""
{
"@context": "/contexts/Brand",
"@id": "/brands/1",
"@type": "Brand",
"car": [
"/dummy_cars/1",
"/dummy_cars/2"
],
"id": 1
}
"""
Scenario: Remove the first car of the relation
When I add "Content-Type" header equal to "application/ld+json"
And I send a "PUT" request to "/brands/1" with body:
"""
{"car": ["/dummy_cars/2"]}
"""
And the JSON should be equal to:
"""
{
"@context": "/contexts/Brand",
"@id": "/brands/1",
"@type": "Brand",
"car": [
"/dummy_cars/2"
],
"id": 1
}
"""
The json is equal to:
{
"@context": "\/contexts\/Brand",
"@id": "\/brands\/1",
"@type": "Brand",
"car": {
"1": "\/dummy_cars\/2"
},
"id": 1
} (Behat\Mink\Exception\ExpectationException)
I suspect the denormalization but I might be wrong.