diff --git a/features/graphql/query.feature b/features/graphql/query.feature index a8a6a755831..ffc931aa350 100644 --- a/features/graphql/query.feature +++ b/features/graphql/query.feature @@ -61,12 +61,12 @@ Feature: GraphQL query support And the JSON node "data.multiRelationsDummy.manyToOneRelation.name" should be equal to "RelatedManyToOneDummy #2" And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges" should have 2 element And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[1].node.id" should not be null - And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[0].node.name" should be equal to "RelatedManyToManyDummy12" - And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[1].node.name" should be equal to "RelatedManyToManyDummy22" + And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[0].node.name" should match "#RelatedManyToManyDummy(1|2)2#" + And the JSON node "data.multiRelationsDummy.manyToManyRelations.edges[1].node.name" should match "#RelatedManyToManyDummy(1|2)2#" And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges" should have 3 element And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[1].node.id" should not be null - And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[0].node.name" should be equal to "RelatedOneToManyDummy12" - And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[2].node.name" should be equal to "RelatedOneToManyDummy32" + And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[0].node.name" should match "#RelatedOneToManyDummy(1|3)2#" + And the JSON node "data.multiRelationsDummy.oneToManyRelations.edges[2].node.name" should match "#RelatedOneToManyDummy(1|3)2#" @createSchema @!mongodb Scenario: Retrieve an item with child relation to the same resource diff --git a/features/hal/max_depth.feature b/features/hal/max_depth.feature index d68f1ba1ba9..ef1b9601dd7 100644 --- a/features/hal/max_depth.feature +++ b/features/hal/max_depth.feature @@ -19,79 +19,33 @@ Feature: Max depth handling Then the response status code should be 201 And the response should be in JSON And the header "Content-Type" should be equal to "application/hal+json; charset=utf-8" - And the JSON should be equal to: - """ - { - "_links": { - "self": { - "href": "/max_depth_eager_dummies/1" - }, - "child": { - "href": "/max_depth_eager_dummies/2" - } - }, - "_embedded": { - "child": { - "_links": { - "self": { - "href": "/max_depth_eager_dummies/2" - } - }, - "id": 2, - "name": "level 2" - } - }, - "id": 1, - "name": "level 1" - } - """ + Then the JSON node "_embedded" should exist + Then the JSON node "_embedded.child" should exist + Then the JSON node "_embedded.child._embedded" should not exist - Scenario: Add a 2nd level of descendants + Scenario: Create a resource with 2 levels of descendants When I add "Accept" header equal to "application/hal+json" And I add "Content-Type" header equal to "application/json" - And I send a "PUT" request to "max_depth_eager_dummies/1" with body: + And I send a "POST" request to "/max_depth_eager_dummies" with body: """ { - "id": "/max_depth_eager_dummies/1", + "name": "level 1", "child": { - "id": "/max_depth_eager_dummies/2", + "name": "level 2", "child": { "name": "level 3" } } } """ - And the response status code should be 200 + And the response status code should be 201 And the response should be in JSON And the header "Content-Type" should be equal to "application/hal+json; charset=utf-8" - And the JSON should be equal to: - """ - { - "_links": { - "self": { - "href": "/max_depth_eager_dummies/1" - }, - "child": { - "href": "/max_depth_eager_dummies/2" - } - }, - "_embedded": { - "child": { - "_links": { - "self": { - "href": "/max_depth_eager_dummies/2" - } - }, - "id": 2, - "name": "level 2" - } - }, - "id": 1, - "name": "level 1" - } - """ + Then the JSON node "_embedded" should exist + Then the JSON node "_embedded.child" should exist + Then the JSON node "_embedded.child._embedded" should not exist - Scenario: Add a 2nd level of descendants when eager fetching is disabled + Scenario: Create a resource with 1 levels of descendants then add a 2nd level of descendants when eager fetching is disabled Given there is a max depth dummy with 1 level of descendants When I add "Accept" header equal to "application/hal+json" And I add "Content-Type" header equal to "application/json" @@ -110,29 +64,6 @@ Feature: Max depth handling Then the response status code should be 200 And the response should be in JSON And the header "Content-Type" should be equal to "application/hal+json; charset=utf-8" - And the JSON should be equal to: - """ - { - "_links": { - "self": { - "href": "/max_depth_dummies/1" - }, - "child": { - "href": "/max_depth_dummies/2" - } - }, - "_embedded": { - "child": { - "_links": { - "self": { - "href": "/max_depth_dummies/2" - } - }, - "id": 2, - "name": "level 2" - } - }, - "id": 1, - "name": "level 1" - } - """ + Then the JSON node "_embedded" should exist + Then the JSON node "_embedded.child" should exist + Then the JSON node "_embedded.child._embedded" should not exist diff --git a/features/jsonapi/collection_attributes.feature b/features/jsonapi/collection_attributes.feature index 5a506c56a31..6603d36087d 100644 --- a/features/jsonapi/collection_attributes.feature +++ b/features/jsonapi/collection_attributes.feature @@ -14,32 +14,7 @@ Feature: JSON API collections support Then the response status code should be 200 And the response should be in JSON And the JSON should be valid according to the JSON API schema - And the JSON should be equal to: - """ - { - "data": { - "id": "/circular_references/1", - "type": "CircularReference", - "relationships": { - "parent": { - "data": { - "type": "CircularReference", - "id": "/circular_references/1" - } - }, - "children": { - "data": [ - { - "type": "CircularReference", - "id": "/circular_references/1" - }, - { - "type": "CircularReference", - "id": "/circular_references/2" - } - ] - } - } - } - } - """ + And the JSON node "data.id" should be equal to "/circular_references/1" + And the JSON node "data.relationships.parent.data.id" should be equal to "/circular_references/1" + And the JSON node "data.relationships.children.data[0].id" should match "#/circular_references/(1|2)#" + And the JSON node "data.relationships.children.data[1].id" should match "#/circular_references/(1|2)#" diff --git a/features/jsonld/max_depth.feature b/features/jsonld/max_depth.feature index 529788a269e..58c2e5c1249 100644 --- a/features/jsonld/max_depth.feature +++ b/features/jsonld/max_depth.feature @@ -18,54 +18,26 @@ Feature: Max depth handling Then the response status code should be 201 And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" - And the JSON should be equal to: - """ - { - "@context": "/contexts/MaxDepthEagerDummy", - "@id": "/max_depth_eager_dummies/1", - "@type": "MaxDepthEagerDummy", - "id": 1, - "name": "level 1", - "child": { - "@id": "/max_depth_eager_dummies/2", - "@type": "MaxDepthEagerDummy", - "id": 2, - "name": "level 2" - } - } - """ + Then the JSON node "child" should exist + Then the JSON node "child.name" should be equal to "level 2" Scenario: Add a 2nd level of descendants When I add "Content-Type" header equal to "application/ld+json" - And I send a "PUT" request to "max_depth_eager_dummies/1" with body: + And I send a "POST" request to "/max_depth_eager_dummies" with body: """ { - "@id": "/max_depth_eager_dummies/1", + "name": "level 1", "child": { - "@id": "/max_depth_eager_dummies/2", + "name": "level 2", "child": { "name": "level 3" } } } """ - And the response status code should be 200 + And the response status code should be 201 And the response should be in JSON And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" - And the JSON should be equal to: - """ - { - "@context": "/contexts/MaxDepthEagerDummy", - "@id": "/max_depth_eager_dummies/1", - "@type": "MaxDepthEagerDummy", - "id": 1, - "name": "level 1", - "child": { - "@id": "/max_depth_eager_dummies/2", - "@type": "MaxDepthEagerDummy", - "id": 2, - "name": "level 2" - } - } - """ - + Then the JSON node "child" should exist + Then the JSON node "child.name" should be equal to "level 2" + Then the JSON node "child.child" should not exist diff --git a/tests/Behat/DoctrineContext.php b/tests/Behat/DoctrineContext.php index a271b8d895b..fa4facf60b4 100644 --- a/tests/Behat/DoctrineContext.php +++ b/tests/Behat/DoctrineContext.php @@ -1483,17 +1483,21 @@ public function thePasswordForUserShouldBeHashed(string $password, string $user) public function createProductWithOffers(): void { $offer = $this->buildDummyOffer(); + $offer->setId(1); $offer->setValue(2); + $aggregate = $this->buildDummyAggregateOffer(); $aggregate->setValue(1); $aggregate->addOffer($offer); $product = $this->buildDummyProduct(); + $product->setId(2); $product->setName('Dummy product'); $product->addOffer($aggregate); $relatedProduct = $this->buildDummyProduct(); $relatedProduct->setName('Dummy related product'); + $relatedProduct->setId(1); $relatedProduct->setParent($product); $product->addRelatedProduct($relatedProduct); diff --git a/tests/Fixtures/TestBundle/Document/DummyOffer.php b/tests/Fixtures/TestBundle/Document/DummyOffer.php index 518829e632b..7f917b8141d 100644 --- a/tests/Fixtures/TestBundle/Document/DummyOffer.php +++ b/tests/Fixtures/TestBundle/Document/DummyOffer.php @@ -53,6 +53,11 @@ public function getId(): ?int return $this->id; } + public function setId(int $id): void + { + $this->id = $id; + } + public function getValue(): int { return $this->value; diff --git a/tests/Fixtures/TestBundle/Document/DummyProduct.php b/tests/Fixtures/TestBundle/Document/DummyProduct.php index 065956e5ee7..0887236029b 100644 --- a/tests/Fixtures/TestBundle/Document/DummyProduct.php +++ b/tests/Fixtures/TestBundle/Document/DummyProduct.php @@ -35,7 +35,7 @@ class DummyProduct /** * @var int The id */ - #[ODM\Id(strategy: 'INCREMENT', type: 'int')] + #[ODM\Id(strategy: 'None', type: 'int')] private ?int $id = null; #[ODM\ReferenceMany(targetDocument: DummyAggregateOffer::class, mappedBy: 'product', cascade: ['persist'])] private Collection|iterable $offers; @@ -76,6 +76,11 @@ public function getId(): ?int return $this->id; } + public function setId(int $id): void + { + $this->id = $id; + } + public function getName(): string { return $this->name; diff --git a/tests/Fixtures/TestBundle/Entity/DummyOffer.php b/tests/Fixtures/TestBundle/Entity/DummyOffer.php index 5e9d52dad81..47c9c42142d 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyOffer.php +++ b/tests/Fixtures/TestBundle/Entity/DummyOffer.php @@ -55,6 +55,11 @@ public function getId(): ?int return $this->id; } + public function setId(int $id): void + { + $this->id = $id; + } + public function getValue(): int { return $this->value; diff --git a/tests/Fixtures/TestBundle/Entity/DummyProduct.php b/tests/Fixtures/TestBundle/Entity/DummyProduct.php index f2a5475d46a..0f34fe8174d 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyProduct.php +++ b/tests/Fixtures/TestBundle/Entity/DummyProduct.php @@ -37,7 +37,6 @@ class DummyProduct */ #[ORM\Column(type: 'integer')] #[ORM\Id] - #[ORM\GeneratedValue(strategy: 'AUTO')] private ?int $id = null; /** * @var Collection @@ -84,6 +83,11 @@ public function getId(): ?int return $this->id; } + public function setId(int $id): void + { + $this->id = $id; + } + public function getName(): string { return $this->name;