Skip to content

Commit 30fdef9

Browse files
test: do not rely on order of insertion (#5709)
* fix: add conflict on doctrine/orm:2.16.0 See doctrine/orm#10547 * fix: extend above 2.16 as 2.17 is bugged too * fix(maxdepthEager): relying on node existance instead of the full representation * fix: correction for more insert order checks * fix: correction for more insert order checks * fix: typo
1 parent 9faba9b commit 30fdef9

File tree

9 files changed

+57
-156
lines changed

9 files changed

+57
-156
lines changed

features/graphql/query.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ Feature: GraphQL query support
6161
And the JSON node "data.multiRelationsDummy.manyToOneRelation.name" should be equal to "RelatedManyToOneDummy #2"
6262
And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges" should have 2 element
6363
And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[1].node.id" should not be null
64-
And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[0].node.name" should be equal to "RelatedManyToManyDummy12"
65-
And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[1].node.name" should be equal to "RelatedManyToManyDummy22"
64+
And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[0].node.name" should match "#RelatedManyToManyDummy(1|2)2#"
65+
And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[1].node.name" should match "#RelatedManyToManyDummy(1|2)2#"
6666
And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges" should have 3 element
6767
And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[1].node.id" should not be null
68-
And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[0].node.name" should be equal to "RelatedOneToManyDummy12"
69-
And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[2].node.name" should be equal to "RelatedOneToManyDummy32"
68+
And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[0].node.name" should match "#RelatedOneToManyDummy(1|3)2#"
69+
And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[2].node.name" should match "#RelatedOneToManyDummy(1|3)2#"
7070

7171
@createSchema @!mongodb
7272
Scenario: Retrieve an item with child relation to the same resource

features/hal/max_depth.feature

Lines changed: 15 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -19,79 +19,33 @@ Feature: Max depth handling
1919
Then the response status code should be 201
2020
And the response should be in JSON
2121
And the header "Content-Type" should be equal to "application/hal+json; charset=utf-8"
22-
And the JSON should be equal to:
23-
"""
24-
{
25-
"_links": {
26-
"self": {
27-
"href": "/max_depth_eager_dummies/1"
28-
},
29-
"child": {
30-
"href": "/max_depth_eager_dummies/2"
31-
}
32-
},
33-
"_embedded": {
34-
"child": {
35-
"_links": {
36-
"self": {
37-
"href": "/max_depth_eager_dummies/2"
38-
}
39-
},
40-
"id": 2,
41-
"name": "level 2"
42-
}
43-
},
44-
"id": 1,
45-
"name": "level 1"
46-
}
47-
"""
22+
Then the JSON node "_embedded" should exist
23+
Then the JSON node "_embedded.child" should exist
24+
Then the JSON node "_embedded.child._embedded" should not exist
4825

49-
Scenario: Add a 2nd level of descendants
26+
Scenario: Create a resource with 2 levels of descendants
5027
When I add "Accept" header equal to "application/hal+json"
5128
And I add "Content-Type" header equal to "application/json"
52-
And I send a "PUT" request to "max_depth_eager_dummies/1" with body:
29+
And I send a "POST" request to "/max_depth_eager_dummies" with body:
5330
"""
5431
{
55-
"id": "/max_depth_eager_dummies/1",
32+
"name": "level 1",
5633
"child": {
57-
"id": "/max_depth_eager_dummies/2",
34+
"name": "level 2",
5835
"child": {
5936
"name": "level 3"
6037
}
6138
}
6239
}
6340
"""
64-
And the response status code should be 200
41+
And the response status code should be 201
6542
And the response should be in JSON
6643
And the header "Content-Type" should be equal to "application/hal+json; charset=utf-8"
67-
And the JSON should be equal to:
68-
"""
69-
{
70-
"_links": {
71-
"self": {
72-
"href": "/max_depth_eager_dummies/1"
73-
},
74-
"child": {
75-
"href": "/max_depth_eager_dummies/2"
76-
}
77-
},
78-
"_embedded": {
79-
"child": {
80-
"_links": {
81-
"self": {
82-
"href": "/max_depth_eager_dummies/2"
83-
}
84-
},
85-
"id": 2,
86-
"name": "level 2"
87-
}
88-
},
89-
"id": 1,
90-
"name": "level 1"
91-
}
92-
"""
44+
Then the JSON node "_embedded" should exist
45+
Then the JSON node "_embedded.child" should exist
46+
Then the JSON node "_embedded.child._embedded" should not exist
9347

94-
Scenario: Add a 2nd level of descendants when eager fetching is disabled
48+
Scenario: Create a resource with 1 levels of descendants then add a 2nd level of descendants when eager fetching is disabled
9549
Given there is a max depth dummy with 1 level of descendants
9650
When I add "Accept" header equal to "application/hal+json"
9751
And I add "Content-Type" header equal to "application/json"
@@ -110,29 +64,6 @@ Feature: Max depth handling
11064
Then the response status code should be 200
11165
And the response should be in JSON
11266
And the header "Content-Type" should be equal to "application/hal+json; charset=utf-8"
113-
And the JSON should be equal to:
114-
"""
115-
{
116-
"_links": {
117-
"self": {
118-
"href": "/max_depth_dummies/1"
119-
},
120-
"child": {
121-
"href": "/max_depth_dummies/2"
122-
}
123-
},
124-
"_embedded": {
125-
"child": {
126-
"_links": {
127-
"self": {
128-
"href": "/max_depth_dummies/2"
129-
}
130-
},
131-
"id": 2,
132-
"name": "level 2"
133-
}
134-
},
135-
"id": 1,
136-
"name": "level 1"
137-
}
138-
"""
67+
Then the JSON node "_embedded" should exist
68+
Then the JSON node "_embedded.child" should exist
69+
Then the JSON node "_embedded.child._embedded" should not exist

features/jsonapi/collection_attributes.feature

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,7 @@ Feature: JSON API collections support
1414
Then the response status code should be 200
1515
And the response should be in JSON
1616
And the JSON should be valid according to the JSON API schema
17-
And the JSON should be equal to:
18-
"""
19-
{
20-
"data": {
21-
"id": "/circular_references/1",
22-
"type": "CircularReference",
23-
"relationships": {
24-
"parent": {
25-
"data": {
26-
"type": "CircularReference",
27-
"id": "/circular_references/1"
28-
}
29-
},
30-
"children": {
31-
"data": [
32-
{
33-
"type": "CircularReference",
34-
"id": "/circular_references/1"
35-
},
36-
{
37-
"type": "CircularReference",
38-
"id": "/circular_references/2"
39-
}
40-
]
41-
}
42-
}
43-
}
44-
}
45-
"""
17+
And the JSON node "data.id" should be equal to "/circular_references/1"
18+
And the JSON node "data.relationships.parent.data.id" should be equal to "/circular_references/1"
19+
And the JSON node "data.relationships.children.data[0].id" should match "#/circular_references/(1|2)#"
20+
And the JSON node "data.relationships.children.data[1].id" should match "#/circular_references/(1|2)#"

features/jsonld/max_depth.feature

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,54 +18,26 @@ Feature: Max depth handling
1818
Then the response status code should be 201
1919
And the response should be in JSON
2020
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
21-
And the JSON should be equal to:
22-
"""
23-
{
24-
"@context": "/contexts/MaxDepthEagerDummy",
25-
"@id": "/max_depth_eager_dummies/1",
26-
"@type": "MaxDepthEagerDummy",
27-
"id": 1,
28-
"name": "level 1",
29-
"child": {
30-
"@id": "/max_depth_eager_dummies/2",
31-
"@type": "MaxDepthEagerDummy",
32-
"id": 2,
33-
"name": "level 2"
34-
}
35-
}
36-
"""
21+
Then the JSON node "child" should exist
22+
Then the JSON node "child.name" should be equal to "level 2"
3723

3824
Scenario: Add a 2nd level of descendants
3925
When I add "Content-Type" header equal to "application/ld+json"
40-
And I send a "PUT" request to "max_depth_eager_dummies/1" with body:
26+
And I send a "POST" request to "/max_depth_eager_dummies" with body:
4127
"""
4228
{
43-
"@id": "/max_depth_eager_dummies/1",
29+
"name": "level 1",
4430
"child": {
45-
"@id": "/max_depth_eager_dummies/2",
31+
"name": "level 2",
4632
"child": {
4733
"name": "level 3"
4834
}
4935
}
5036
}
5137
"""
52-
And the response status code should be 200
38+
And the response status code should be 201
5339
And the response should be in JSON
5440
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
55-
And the JSON should be equal to:
56-
"""
57-
{
58-
"@context": "/contexts/MaxDepthEagerDummy",
59-
"@id": "/max_depth_eager_dummies/1",
60-
"@type": "MaxDepthEagerDummy",
61-
"id": 1,
62-
"name": "level 1",
63-
"child": {
64-
"@id": "/max_depth_eager_dummies/2",
65-
"@type": "MaxDepthEagerDummy",
66-
"id": 2,
67-
"name": "level 2"
68-
}
69-
}
70-
"""
71-
41+
Then the JSON node "child" should exist
42+
Then the JSON node "child.name" should be equal to "level 2"
43+
Then the JSON node "child.child" should not exist

tests/Behat/DoctrineContext.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,17 +1483,21 @@ public function thePasswordForUserShouldBeHashed(string $password, string $user)
14831483
public function createProductWithOffers(): void
14841484
{
14851485
$offer = $this->buildDummyOffer();
1486+
$offer->setId(1);
14861487
$offer->setValue(2);
1488+
14871489
$aggregate = $this->buildDummyAggregateOffer();
14881490
$aggregate->setValue(1);
14891491
$aggregate->addOffer($offer);
14901492

14911493
$product = $this->buildDummyProduct();
1494+
$product->setId(2);
14921495
$product->setName('Dummy product');
14931496
$product->addOffer($aggregate);
14941497

14951498
$relatedProduct = $this->buildDummyProduct();
14961499
$relatedProduct->setName('Dummy related product');
1500+
$relatedProduct->setId(1);
14971501
$relatedProduct->setParent($product);
14981502

14991503
$product->addRelatedProduct($relatedProduct);

tests/Fixtures/TestBundle/Document/DummyOffer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public function getId(): ?int
5353
return $this->id;
5454
}
5555

56+
public function setId(int $id): void
57+
{
58+
$this->id = $id;
59+
}
60+
5661
public function getValue(): int
5762
{
5863
return $this->value;

tests/Fixtures/TestBundle/Document/DummyProduct.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class DummyProduct
3535
/**
3636
* @var int The id
3737
*/
38-
#[ODM\Id(strategy: 'INCREMENT', type: 'int')]
38+
#[ODM\Id(strategy: 'None', type: 'int')]
3939
private ?int $id = null;
4040
#[ODM\ReferenceMany(targetDocument: DummyAggregateOffer::class, mappedBy: 'product', cascade: ['persist'])]
4141
private Collection|iterable $offers;
@@ -76,6 +76,11 @@ public function getId(): ?int
7676
return $this->id;
7777
}
7878

79+
public function setId(int $id): void
80+
{
81+
$this->id = $id;
82+
}
83+
7984
public function getName(): string
8085
{
8186
return $this->name;

tests/Fixtures/TestBundle/Entity/DummyOffer.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public function getId(): ?int
5555
return $this->id;
5656
}
5757

58+
public function setId(int $id): void
59+
{
60+
$this->id = $id;
61+
}
62+
5863
public function getValue(): int
5964
{
6065
return $this->value;

tests/Fixtures/TestBundle/Entity/DummyProduct.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ class DummyProduct
3737
*/
3838
#[ORM\Column(type: 'integer')]
3939
#[ORM\Id]
40-
#[ORM\GeneratedValue(strategy: 'AUTO')]
4140
private ?int $id = null;
4241
/**
4342
* @var Collection<int, DummyAggregateOffer>
@@ -84,6 +83,11 @@ public function getId(): ?int
8483
return $this->id;
8584
}
8685

86+
public function setId(int $id): void
87+
{
88+
$this->id = $id;
89+
}
90+
8791
public function getName(): string
8892
{
8993
return $this->name;

0 commit comments

Comments
 (0)