Skip to content

Commit

Permalink
Merge 61c08d3 into 9f7f1e1
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Aug 3, 2021
2 parents 9f7f1e1 + 61c08d3 commit 16b619c
Show file tree
Hide file tree
Showing 16 changed files with 154 additions and 45 deletions.
23 changes: 23 additions & 0 deletions features/doctrine/search_filter.feature
Expand Up @@ -192,6 +192,7 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Search collection by name (partial)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?name=my"
Expand Down Expand Up @@ -232,6 +233,7 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Search collection by name (partial)
Given there are 30 embedded dummy objects
When I send a "GET" request to "/embedded_dummies?embeddedDummy.dummyName=my"
Expand Down Expand Up @@ -272,6 +274,7 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Search collection by name (partial multiple values)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?name[]=2&name[]=3"
Expand Down Expand Up @@ -312,7 +315,9 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Search collection by name (partial case insensitive)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?dummy=somedummytest1"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -340,7 +345,9 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Search collection by alias (start)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?alias=Ali"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -379,7 +386,9 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Search collection by alias (start multiple values)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?description[]=Sma&description[]=Not"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -419,7 +428,9 @@ Feature: Search filter on collections
"""

@sqlite
@createSchema
Scenario: Search collection by description (word_start)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?description=smart"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -458,8 +469,10 @@ Feature: Search filter on collections
}
"""

@createSchema
@sqlite
Scenario: Search collection by description (word_start multiple values)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?description[]=smart&description[]=so"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -500,7 +513,9 @@ Feature: Search filter on collections

# note on Postgres compared to sqlite the LIKE clause is case sensitive
@postgres
@createSchema
Scenario: Search collection by description (word_start)
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?description=smart"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -539,7 +554,9 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Search for entities within an impossible range
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?name=MuYm"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -568,7 +585,9 @@ Feature: Search filter on collections
"""

@sqlite
@createSchema
Scenario: Search for entities with an existing collection route name
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?relatedDummies=dummy_cars"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -659,7 +678,9 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Get collection by id 10
Given there are 30 dummy objects
When I send a "GET" request to "/dummies?id=10"
Then the response status code should be 200
And the response should be in JSON
Expand Down Expand Up @@ -696,8 +717,10 @@ Feature: Search filter on collections
}
"""

@createSchema
Scenario: Get collection ordered by a non valid properties
When I send a "GET" request to "/dummies?unknown=0"
Given there are 30 dummy objects
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/ld+json; charset=utf-8"
Expand Down
7 changes: 7 additions & 0 deletions features/graphql/query.feature
Expand Up @@ -19,7 +19,9 @@ Feature: GraphQL query support
And the JSON node "data.dummy.name" should be equal to "Dummy #1"
And the JSON node "data.dummy.name_converted" should be equal to "Converted 1"

@createSchema
Scenario: Retrieve a Relay Node
Given there are 2 dummy objects with relatedDummy
When I send the following GraphQL request:
"""
{
Expand All @@ -37,7 +39,9 @@ Feature: GraphQL query support
And the JSON node "data.node.id" should be equal to "/dummies/1"
And the JSON node "data.node.name" should be equal to "Dummy #1"

@createSchema
Scenario: Retrieve an item with an iterable field
Given there are 2 dummy objects with relatedDummy
Given there are 2 dummy objects with JSON and array data
When I send the following GraphQL request:
"""
Expand All @@ -59,6 +63,7 @@ Feature: GraphQL query support
And the JSON node "data.dummy.jsonData.bar" should be equal to 5
And the JSON node "data.dummy.arrayData[2]" should be equal to baz

@createSchema
Scenario: Retrieve an item with an iterable null field
Given there are 2 dummy with null JSON objects
When I send the following GraphQL request:
Expand All @@ -76,7 +81,9 @@ Feature: GraphQL query support
And the JSON node "data.withJsonDummy.id" should be equal to "/with_json_dummies/2"
And the JSON node "data.withJsonDummy.json" should be null

@createSchema
Scenario: Retrieve an item through a GraphQL query with variables
Given there are 2 dummy objects with relatedDummy
When I have the following GraphQL request:
"""
query DummyWithId($itemId: ID = "/dummies/1") {
Expand Down
2 changes: 2 additions & 0 deletions features/hal/input_output.feature
Expand Up @@ -2,6 +2,8 @@ Feature: HAL DTO input and output
In order to use a hypermedia API
As a client software developer
I need to be able to use DTOs on my resources as Input or Output objects.
TODO: in 3.0 we should change the generated IRIs, /dummy_dto_custom_output/1 should retrieve /dummy_dto_custom_output/1 not /dumy_dto_customs/1
for the collection we can search for an Operation with the same Output class as the given one for the collection

Background:
Given I add "Accept" header equal to "application/hal+json"
Expand Down
2 changes: 2 additions & 0 deletions features/main/composite.feature
Expand Up @@ -101,6 +101,7 @@ Feature: Retrieve data with Composite identifiers
}
"""

@createSchema
Scenario: Get the first composite relation with a reverse identifiers order
Given there are Composite identifier objects
When I send a "GET" request to "/composite_relations/compositeLabel=1;compositeItem=1"
Expand All @@ -119,6 +120,7 @@ Feature: Retrieve data with Composite identifiers
}
"""

@createSchema
Scenario: Get the first composite relation with a missing identifier
Given there are Composite identifier objects
When I send a "GET" request to "/composite_relations/compositeLabel=1;"
Expand Down
21 changes: 20 additions & 1 deletion features/main/custom_normalized.feature
Expand Up @@ -30,6 +30,7 @@ Feature: Using custom normalized entity
}
"""

@createSchema
Scenario: Create a resource with a custom normalized dummy
When I add "Content-Type" header equal to "application/json"
When I add "Accept" header equal to "application/json"
Expand All @@ -53,7 +54,26 @@ Feature: Using custom normalized entity
}
"""

@createSchema
Scenario: Create a resource with a custom normalized dummy and an id
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/custom_normalized_dummies" with body:
"""
{
"name": "My Dummy",
"alias": "My alias"
}
"""
Then the response status code should be 201
When I add "Content-Type" header equal to "application/json"
When I add "Accept" header equal to "application/json"
And I send a "POST" request to "/related_normalized_dummies" with body:
"""
{
"name": "My Dummy"
}
"""
Then the response status code should be 201
When I add "Content-Type" header equal to "application/json"
When I add "Accept" header equal to "application/json"
And I send a "PUT" request to "/related_normalized_dummies/1" with body:
Expand Down Expand Up @@ -86,7 +106,6 @@ Feature: Using custom normalized entity
}
"""


Scenario: Get a custom normalized dummy resource
When I send a "GET" request to "/custom_normalized_dummies/1"
Then the response status code should be 200
Expand Down
3 changes: 3 additions & 0 deletions features/main/custom_operation.feature
Expand Up @@ -71,6 +71,7 @@ Feature: Custom operation
}
"""

@createSchema
Scenario: Create a payment
When I send a "POST" request to "/payments" with body:
"""
Expand All @@ -93,7 +94,9 @@ Feature: Custom operation
}
"""

@createSchema
Scenario: Void a payment
Given There is a payment
When I send a "POST" request to "/payments/1/void"
Then the response status code should be 201
And the response should be in JSON
Expand Down
69 changes: 36 additions & 33 deletions features/main/relation.feature
Expand Up @@ -396,39 +396,7 @@ Feature: Relations support
}
"""

Scenario: Issue #1222
Given there are people having pets
When I add "Content-Type" header equal to "application/ld+json"
And I send a "GET" request to "/people"
Then the response status code should be 200
And the response should be in JSON
And the JSON should be a superset of:
"""
{
"@context": "/contexts/Person",
"@id": "/people",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/people/1",
"@type": "Person",
"name": "foo",
"pets": [
{
"@type": "PersonToPet",
"pet": {
"@id": "/pets/1",
"@type": "Pet",
"name": "bar"
}
}
]
}
],
"hydra:totalItems": 1
}
"""

@createSchema
Scenario: Eager load relations should not be duplicated
Given there is an order with same customer and recipient
When I add "Content-Type" header equal to "application/ld+json"
Expand Down Expand Up @@ -545,3 +513,38 @@ Feature: Relations support
]
}
"""

@createSchema
Scenario: Issue #1222
Given there are people having pets
When I add "Content-Type" header equal to "application/ld+json"
And I send a "GET" request to "/people"
Then the response status code should be 200
And the response should be in JSON
And the JSON should be a superset of:
"""
{
"@context": "/contexts/Person",
"@id": "/people",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/people/1",
"@type": "Person",
"name": "foo",
"pets": [
{
"@type": "PersonToPet",
"pet": {
"@id": "/pets/1",
"@type": "Pet",
"name": "bar"
}
}
]
}
],
"hydra:totalItems": 1
}
"""

6 changes: 6 additions & 0 deletions features/main/subresource.feature
Expand Up @@ -24,13 +24,16 @@ Feature: Subresource support
}
"""

@createSchema
Scenario: Get a non existent subresource
Given there is an answer "42" to the question "What's the answer to the Ultimate Question of Life, the Universe and Everything?"
When I send a "GET" request to "/questions/999999/answer"
Then the response status code should be 404
And the response should be in JSON

@createSchema
Scenario: Get recursive subresource one to many relation
Given there is an answer "42" to the question "What's the answer to the Ultimate Question of Life, the Universe and Everything?"
When I send a "GET" request to "/questions/1/answer/related_questions"
And the response status code should be 200
And the response should be in JSON
Expand All @@ -53,6 +56,7 @@ Feature: Subresource support
}
"""

@createSchema
Scenario: Get the subresource relation collection
Given there is a dummy object with a fourth level relation
When I send a "GET" request to "/dummies/1/related_dummies"
Expand Down Expand Up @@ -142,7 +146,9 @@ Feature: Subresource support
}
"""

@createSchema
Scenario: Get filtered embedded relation subresource collection
Given there is a dummy object with a fourth level relation
When I send a "GET" request to "/dummies/1/related_dummies?name=Hello"
Then the response status code should be 200
And the response should be in JSON
Expand Down
5 changes: 5 additions & 0 deletions phpstan.neon.dist
Expand Up @@ -43,6 +43,11 @@ parameters:
- fail
ignoreErrors:
# False positives
-
message: "#Parameter \\#2 \\$dqlPart of method Doctrine\\\\ORM\\\\QueryBuilder::add\\(\\) expects array<'join'\\|int, array<int\\|string, object>\\|string>\\|object\\|string, array\\('o' => Doctrine\\\\ORM\\\\Query\\\\Expr\\\\Join\\) given\\.#"
paths:
- tests/Bridge/Doctrine/Orm/Extension/FilterEagerLoadingExtensionTest.php
- '#Parameter \#1 \$function of function call_user_func expects callable\(\): mixed, non-empty-string given\.#'
-
message: '#Strict comparison using !== between .+ and .+ will always evaluate to false\.#'
paths:
Expand Down
Expand Up @@ -133,7 +133,7 @@ private function gatherRelationTags(EntityManagerInterface $em, $entity): void

private function addTagsFor($value): void
{
if (!$value) {
if (!$value || is_scalar($value)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Api/FilterCollectionFactoryTest.php
Expand Up @@ -43,7 +43,7 @@ public function testCreateFilterCollectionFromLocator()
$filterCollection = (new FilterCollectionFactory(['foo', 'bar']))->createFilterCollectionFromLocator($filterLocatorProphecy->reveal());

$this->assertArrayNotHasKey('bar', $filterCollection);
$this->assertArrayHasKey('foo', $filterCollection);
$this->assertTrue(isset($filterCollection['foo']));
$this->assertInstanceOf(FilterInterface::class, $filterCollection['foo']);
$this->assertEquals(new FilterCollection(['foo' => $filter]), $filterCollection);
}
Expand Down

0 comments on commit 16b619c

Please sign in to comment.