Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ jobs:
composer remove --dev --no-interaction --no-progress --no-update --ansi \
doctrine/mongodb-odm \
doctrine/mongodb-odm-bundle
# https://github.com/doctrine/dbal/issues/5570
- name: Fix Doctrine dependencies
if: (startsWith(matrix.php, '7.1') || startsWith(matrix.php, '7.2') || startsWith(matrix.php, '7.3'))
run: composer require "doctrine/orm:<2.13" --dev --no-interaction --no-progress --ansi
- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
- name: Require Symfony components
Expand Down Expand Up @@ -230,6 +234,10 @@ jobs:
doctrine/mongodb-odm-bundle
- name: Update project dependencies
run: composer update --no-interaction --no-progress --ansi
# https://github.com/doctrine/dbal/issues/5570
- name: Fix Doctrine dependencies
if: (startsWith(matrix.php, '7.1') || startsWith(matrix.php, '7.2') || startsWith(matrix.php, '7.3'))
run: composer require "doctrine/orm:<2.13" --dev --no-interaction --no-progress --ansi
- name: Require Symfony components
if: (!startsWith(matrix.php, '7.1'))
run: composer require symfony/uid --dev --no-interaction --no-progress --ansi
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"justinrainbow/json-schema": "^5.2.1",
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.1",
"phpdocumentor/type-resolver": "^0.3 || ^0.4 || ^1.4",
"phpspec/prophecy": "^1.10",
"phpstan/extension-installer": "^1.1",
"phpstan/phpstan": "^1.1",
"phpstan/phpstan-doctrine": "^1.0",
Expand Down
128 changes: 128 additions & 0 deletions features/hal/item_uri_template.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
@php8
@v3
Feature: Exposing a collection of objects should use the specified operation to generate the IRI

Scenario: Get a collection of objects without any itemUriTemplate should generate the IRI from the first Get operation
When I add "Accept" header equal to "application/hal+json"
And I send a "GET" request to "/cars"
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 HAL schema
And the header "Content-Type" should be equal to "application/hal+json; charset=utf-8"
And the JSON should be valid according to this schema:
"""
{
"type": "object",
"additionalProperties": false,
"required": ["_links", "_embedded", "totalItems"],
"properties": {
"_links": {
"type": "object",
"properties": {
"self": {
"type": "object",
"properties": {"href": {"pattern": "^/cars$"}}
},
"item": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "object",
"properties": {"href": {"pattern": "^/cars/.+$"}}
}
}
}
},
"totalItems": {"type":"number", "minimum": 2, "maximum": 2},
"_embedded": {
"type": "object",
"properties": {
"item": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "object",
"properties": {
"_links": {
"type": "object",
"properties": {
"self": {
"type": "object",
"properties": {"href": {"pattern": "^/cars/.+$"}}
}
}
},
"id": {"type": "string"},
"owner": {"type": "string"}
}
}
}
}
}
}
}
"""

Scenario: Get a collection of objects with an itemUriTemplate should generate the IRI from the correct operation
When I add "Accept" header equal to "application/hal+json"
And I send a "GET" request to "/brands/renault/cars"
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 valid according to this schema:
"""
{
"type": "object",
"additionalProperties": false,
"required": ["_links", "_embedded", "totalItems"],
"properties": {
"_links": {
"type": "object",
"properties": {
"self": {
"type": "object",
"properties": {"href": {"pattern": "^/brands/renault/cars$"}}
},
"item": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "object",
"properties": {"href": {"pattern": "^/brands/renault/cars/.+$"}}
}
}
}
},
"totalItems": {"type":"number", "minimum": 2, "maximum": 2},
"_embedded": {
"type": "object",
"properties": {
"item": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"items": {
"type": "object",
"properties": {
"_links": {
"type": "object",
"properties": {
"self": {
"type": "object",
"properties": {"href": {"pattern": "^/brands/renault/cars/.+$"}}
}
}
},
"id": {"type": "string"},
"owner": {"type": "string"}
}
}
}
}
}
}
}
"""
131 changes: 131 additions & 0 deletions features/hydra/item_uri_template.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
@php8
@v3
Feature: Exposing a collection of objects should use the specified operation to generate the IRI

Scenario: Get a collection of objects without any itemUriTemplate should generate the IRI from the first Get operation
When I send a "GET" request to "/cars"
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"
And the JSON should be valid according to this schema:
"""
{
"type": "object",
"additionalProperties": false,
"required": ["@context", "@id", "@type", "hydra:member", "hydra:totalItems"],
"properties": {
"@context": {"pattern": "^/contexts/Car$"},
"@id": {"pattern": "^/cars$"},
"@type": {"pattern": "^hydra:Collection$"},
"hydra:member": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["@id", "@type", "id", "owner"],
"properties": {
"@id": {"pattern": "^/cars/.+$"},
"@type": {"pattern": "^Car$"},
"id": {"type": "string"},
"owner": {"type": "string"}
}
}
},
"hydra:totalItems": {"type": "integer", "minimum": 2, "maximum": 2}
}
}
"""

Scenario: Get a collection of objects with an itemUriTemplate should generate the IRI from the correct operation
When I send a "GET" request to "/brands/renault/cars"
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"
And the JSON should be valid according to this schema:
"""
{
"type": "object",
"additionalProperties": false,
"required": ["@context", "@id", "@type", "hydra:member", "hydra:totalItems"],
"properties": {
"@context": {"pattern": "^/contexts/Car$"},
"@id": {"pattern": "^/brands/renault/cars$"},
"@type": {"pattern": "^hydra:Collection$"},
"hydra:member": {
"type": "array",
"minItems": 2,
"maxItems": 2,
"uniqueItems": true,
"items": {
"type": "object",
"additionalProperties": false,
"required": ["@id", "@type", "id", "owner"],
"properties": {
"@id": {"pattern": "^/brands/renault/cars/.+$"},
"@type": {"pattern": "^Car$"},
"id": {"type": "string"},
"owner": {"type": "string"}
}
}
},
"hydra:totalItems": {"type": "integer", "minimum": 2, "maximum": 2}
}
}
"""

Scenario: Create an object without an itemUriTemplate should generate the IRI from the first Get operation
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/cars" with body:
"""
{
"owner": "Vincent"
}
"""
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 valid according to this schema:
"""
{
"type": "object",
"additionalProperties": false,
"required": ["@id", "@type", "id", "owner"],
"properties": {
"@context": {"pattern": "^/contexts/Car$"},
"@id": {"pattern": "^/cars/.+$"},
"@type": {"pattern": "^Car$"},
"id": {"type": "string"},
"owner": {"type": "string"}
}
}
"""

Scenario: Create an object with an itemUriTemplate should generate the IRI from the correct operation
When I add "Content-Type" header equal to "application/json"
And I send a "POST" request to "/brands/renault/cars" with body:
"""
{
"owner": "Vincent"
}
"""
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 valid according to this schema:
"""
{
"type": "object",
"additionalProperties": false,
"required": ["@id", "@type", "id", "owner"],
"properties": {
"@context": {"pattern": "^/contexts/Car$"},
"@id": {"pattern": "^/brands/renault/cars/.+$"},
"@type": {"pattern": "^Car$"},
"id": {"type": "string"},
"owner": {"type": "string"}
}
}
"""
Loading