Skip to content

Commit

Permalink
update composer.json & fix behat tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thbil committed Oct 19, 2020
1 parent 044bebf commit 9300d58
Show file tree
Hide file tree
Showing 15 changed files with 78 additions and 54 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
},
"require-dev": {
"behat/behat": "^3.1",
"behat/mink": "^1.7",
"behat/mink-browserkit-driver": "^1.3.1",
"behat/mink-extension": "^2.2",
"friends-of-behat/mink": "^1.7",
"friends-of-behat/mink-browserkit-driver": "^1.3.1",
"friends-of-behat/mink-extension": "^2.2",
"behat/symfony2-extension": "^2.1.1",
"behatch/contexts": "^3.1.0",
"doctrine/annotations": "^1.7",
Expand Down
2 changes: 1 addition & 1 deletion features/bootstrap/GraphqlContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public function theGraphQLFieldIsDeprecatedForTheReason(string $fieldName, strin

private function sendGraphqlRequest()
{
$this->request->setHttpHeader('Accept', null);
$this->request->setHttpHeader('Accept', 'application/json');
$this->restContext->iSendARequestTo('GET', '/graphql?'.http_build_query($this->graphqlRequest));
}
}
17 changes: 2 additions & 15 deletions features/bootstrap/HttpHeaderContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
declare(strict_types=1);

use Behat\Behat\Context\Context;
use Behat\Behat\Hook\Scope\AfterStepScope;
use Behatch\HttpCall\Request;

final class HttpHeaderContext implements Context
Expand All @@ -25,24 +24,12 @@ public function __construct(Request $request)
}

/**
* Sets the default Accept HTTP header to null (workaround to artificially remove it).
*
* @AfterStep
*/
public function removeAcceptHeaderAfterRequest(AfterStepScope $event)
{
if (preg_match('/^I send a "[A-Z]+" request to ".+"/', $event->getStep()->getText())) {
$this->request->setHttpHeader('Accept', null);
}
}

/**
* Sets the default Accept HTTP header to null (workaround to artificially remove it).
* Sets the default Accept HTTP header to application/ld+json before each scenario.
*
* @BeforeScenario
*/
public function removeAcceptHeaderBeforeScenario()
{
$this->request->setHttpHeader('Accept', null);
$this->request->setHttpHeader('Accept', 'application/ld+json');
}
}
6 changes: 4 additions & 2 deletions features/doctrine/boolean_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ Feature: Boolean filter on collections
And the JSON node "hydra:totalItems" should be equal to 15

Scenario: Get collection filtered by non valid properties
When I send a "GET" request to "/dummies?unknown=0"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?unknown=0"
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 Expand Up @@ -410,7 +411,8 @@ Feature: Boolean filter on collections
"""
And the JSON node "hydra:totalItems" should be equal to 25

When I send a "GET" request to "/dummies?unknown=1"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?unknown=1"
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
45 changes: 30 additions & 15 deletions features/doctrine/date_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Feature: Date filter on collections
@createSchema
Scenario: Get collection filtered by date
Given there are 30 dummy objects with dummyDate
When I send a "GET" request to "/dummies?dummyDate[after]=2015-04-28"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?dummyDate[after]=2015-04-28"
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 Expand Up @@ -49,7 +50,8 @@ Feature: Date filter on collections
}
"""

When I send a "GET" request to "/dummies?dummyDate[before]=2015-04-05"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?dummyDate[before]=2015-04-05"
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 Expand Up @@ -92,7 +94,8 @@ Feature: Date filter on collections
}
"""

When I send a "GET" request to "/dummies?dummyDate[after]=2015-04-28T00:00:00%2B00:00"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?dummyDate[after]=2015-04-28T00:00:00%2B00:00"
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 Expand Up @@ -134,7 +137,8 @@ Feature: Date filter on collections
}
"""

When I send a "GET" request to "/dummies?dummyDate[before]=2015-04-05Z"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?dummyDate[before]=2015-04-05Z"
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 Expand Up @@ -179,7 +183,8 @@ Feature: Date filter on collections

Scenario: Search for entities within a range
# The order should not influence the search
When I send a "GET" request to "/dummies?dummyDate[before]=2015-04-05&dummyDate[after]=2015-04-05"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?dummyDate[before]=2015-04-05&dummyDate[after]=2015-04-05"
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 Expand Up @@ -216,7 +221,8 @@ Feature: Date filter on collections
}
"""

When I send a "GET" request to "/dummies?dummyDate[after]=2015-04-05&dummyDate[before]=2015-04-05"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?dummyDate[after]=2015-04-05&dummyDate[before]=2015-04-05"
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 Expand Up @@ -285,7 +291,8 @@ Feature: Date filter on collections

Scenario: Get collection filtered by association date
Given there are 30 dummy objects with dummyDate and relatedDummy
When I send a "GET" request to "/dummies?relatedDummy.dummyDate[after]=2015-04-28"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?relatedDummy.dummyDate[after]=2015-04-28"
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 Expand Up @@ -329,7 +336,8 @@ Feature: Date filter on collections
}
"""

When I send a "GET" request to "/dummies?relatedDummy.dummyDate[after]=2015-04-28&relatedDummy_dummyDate[after]=2015-04-28"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?relatedDummy.dummyDate[after]=2015-04-28&relatedDummy_dummyDate[after]=2015-04-28"
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 Expand Up @@ -373,7 +381,8 @@ Feature: Date filter on collections
}
"""

When I send a "GET" request to "/dummies?relatedDummy.dummyDate[after]=2015-04-28T00:00:00%2B00:00"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?relatedDummy.dummyDate[after]=2015-04-28T00:00:00%2B00:00"
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 Expand Up @@ -461,13 +470,15 @@ Feature: Date filter on collections
@createSchema
Scenario: Get collection filtered by date that is not a datetime including null after
Given there are 3 dummydate objects with nullable dateIncludeNullAfter
When I send a "GET" request to "/dummy_dates?dateIncludeNullAfter[after]=2015-04-02"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummy_dates?dateIncludeNullAfter[after]=2015-04-02"
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to 2
And the JSON node "hydra:member[0].dateIncludeNullAfter" should be equal to "2015-04-02T00:00:00+00:00"
And the JSON node "hydra:member[1].dateIncludeNullAfter" should be null
When I send a "GET" request to "/dummy_dates?dateIncludeNullAfter[before]=2015-04-02"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummy_dates?dateIncludeNullAfter[before]=2015-04-02"
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to 2
Expand All @@ -477,13 +488,15 @@ Feature: Date filter on collections
@createSchema
Scenario: Get collection filtered by date that is not a datetime including null before
Given there are 3 dummydate objects with nullable dateIncludeNullBefore
When I send a "GET" request to "/dummy_dates?dateIncludeNullBefore[before]=2015-04-01"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummy_dates?dateIncludeNullBefore[before]=2015-04-01"
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to 2
And the JSON node "hydra:member[0].dateIncludeNullBefore" should be equal to "2015-04-01T00:00:00+00:00"
And the JSON node "hydra:member[1].dateIncludeNullBefore" should be null
When I send a "GET" request to "/dummy_dates?dateIncludeNullBefore[after]=2015-04-01"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummy_dates?dateIncludeNullBefore[after]=2015-04-01"
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to 2
Expand All @@ -493,13 +506,15 @@ Feature: Date filter on collections
@createSchema
Scenario: Get collection filtered by date that is not a datetime including null before and after
Given there are 3 dummydate objects with nullable dateIncludeNullBeforeAndAfter
When I send a "GET" request to "/dummy_dates?dateIncludeNullBeforeAndAfter[before]=2015-04-01"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummy_dates?dateIncludeNullBeforeAndAfter[before]=2015-04-01"
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to 2
And the JSON node "hydra:member[0].dateIncludeNullBeforeAndAfter" should be equal to "2015-04-01T00:00:00+00:00"
And the JSON node "hydra:member[1].dateIncludeNullBeforeAndAfter" should be null
When I send a "GET" request to "/dummy_dates?dateIncludeNullBeforeAndAfter[after]=2015-04-02"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummy_dates?dateIncludeNullBeforeAndAfter[after]=2015-04-02"
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8"
And the JSON node "hydra:totalItems" should be equal to 2
Expand Down
12 changes: 8 additions & 4 deletions features/doctrine/order_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,8 @@ Feature: Order filter on collections
"""

Scenario: Get collection ordered by a non valid properties and on which order filter has been enabled in whitelist mode
When I send a "GET" request to "/dummies?order[alias]=asc"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?order[alias]=asc"
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 Expand Up @@ -657,7 +658,8 @@ Feature: Order filter on collections
}
"""

When I send a "GET" request to "/dummies?order[alias]=desc"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?order[alias]=desc"
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 Expand Up @@ -715,7 +717,8 @@ Feature: Order filter on collections
}
"""

When I send a "GET" request to "/dummies?order[unknown]=asc"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?order[unknown]=asc"
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 Expand Up @@ -773,7 +776,8 @@ Feature: Order filter on collections
}
"""

When I send a "GET" request to "/dummies?order[unknown]=desc"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?order[unknown]=desc"
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
6 changes: 4 additions & 2 deletions features/doctrine/search_filter.feature
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ Feature: Search filter on collections
"""

Scenario: Get collection ordered by a non valid properties
When I send a "GET" request to "/dummies?unknown=0"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?unknown=0"
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 Expand Up @@ -615,7 +616,8 @@ Feature: Search filter on collections
}
"""

When I send a "GET" request to "/dummies?unknown=1"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?unknown=1"
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
6 changes: 4 additions & 2 deletions features/http_cache/tags.feature
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,15 @@ Feature: Cache invalidation through HTTP Cache tags
And "/relation_embedders,/relation_embedders/1,/related_dummies/1" IRIs should be purged

Scenario: Create two Relation2
When I add "Content-Type" header equal to "application/ld+json"
When I add "Accept" header equal to "application/ld+json"
And I add "Content-Type" header equal to "application/ld+json"
And I send a "POST" request to "/relation2s" with body:
"""
{
}
"""
When I add "Content-Type" header equal to "application/ld+json"
When I add "Accept" header equal to "application/ld+json"
And I add "Content-Type" header equal to "application/ld+json"
And I send a "POST" request to "/relation2s" with body:
"""
{
Expand Down
6 changes: 4 additions & 2 deletions features/hydra/collection.feature
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,8 @@ Feature: Collections support

@createSchema
Scenario: Allow passing 0 to `itemsPerPage`
When I send a "GET" request to "/dummies?itemsPerPage=0"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?itemsPerPage=0"
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 Expand Up @@ -433,7 +434,8 @@ Feature: Collections support
}
"""

When I send a "GET" request to "/dummies?itemsPerPage=0&page=2"
When I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/dummies?itemsPerPage=0&page=2"
Then the response status code should be 400
And the JSON node "hydra:description" should be equal to "Page should not be greater than 1 if limit is equal to 0"

Expand Down
9 changes: 7 additions & 2 deletions features/main/circular_reference.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ Feature: Circular references handling

@createSchema
Scenario: Create a circular reference
When I add "Content-Type" header equal to "application/ld+json"
When I add "Accept" header equal to "application/ld+json"
And I add "Content-Type" header equal to "application/ld+json"
And I send a "POST" request to "/circular_references" with body:
"""
{}
"""
And I add "Accept" header equal to "application/ld+json"
And I add "Content-Type" header equal to "application/ld+json"
And I send a "PUT" request to "/circular_references/1" with body:
"""
Expand All @@ -34,11 +36,13 @@ Feature: Circular references handling
"""

Scenario: Fetch circular reference
When I add "Content-Type" header equal to "application/ld+json"
When I add "Accept" header equal to "application/ld+json"
And I add "Content-Type" header equal to "application/ld+json"
And I send a "POST" request to "/circular_references" with body:
"""
{}
"""
And I add "Accept" header equal to "application/ld+json"
And I add "Content-Type" header equal to "application/ld+json"
And I send a "PUT" request to "/circular_references/2" with body:
"""
Expand Down Expand Up @@ -67,6 +71,7 @@ Feature: Circular references handling
"children": []
}
"""
And I add "Accept" header equal to "application/ld+json"
And I send a "GET" request to "/circular_references/1"
Then the response status code should be 200
And the JSON should be equal to:
Expand Down
3 changes: 2 additions & 1 deletion features/main/content_negotiation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ Feature: Content Negotiation support
"""

Scenario: Retrieve a collection in XML using the .xml URL
When I send a "GET" request to "/dummies.xml"
When I add "Accept" header equal to "application/xml"
And I send a "GET" request to "/dummies.xml"
Then the response status code should be 200
And the header "Content-Type" should be equal to "application/xml; charset=utf-8"
And the response should be equal to
Expand Down
3 changes: 2 additions & 1 deletion features/main/patch.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Feature: Sending PATCH requets
"""
{"name": "Hello"}
"""
When I add "Content-Type" header equal to "application/ld+json"
When I add "Accept" header equal to "application/ld+json"
And I add "Content-Type" header equal to "application/ld+json"
And I send a "GET" request to "/patch_dummies/1"
Then the header "Accept-Patch" should be equal to "application/merge-patch+json, application/vnd.api+json"

Expand Down
3 changes: 2 additions & 1 deletion features/openapi/docs.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Feature: Documentation support

@createSchema
Scenario: Retrieve the OpenAPI documentation
Given I send a "GET" request to "/docs.json?spec_version=3"
Given I add "Accept" header equal to "application/json"
And I send a "GET" request to "/docs.json?spec_version=3"
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/json; charset=utf-8"
Expand Down
Loading

0 comments on commit 9300d58

Please sign in to comment.