Feature: Manage books and their reviews
In order to manage books and their reviews
As a client software developer
I need to be able to retrieve, create, update and delete them trough the API.
@createSchema
Scenario: Create a book # features/books.feature:8
When I add "Content-Type" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I add "Accept" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I send a "POST" request to "/books" with body: # Sanpi\Behatch\Context\RestContext::iSendARequestToWithBody()
"""
{
"isbn": "9781782164104",
"title": "Persistence in PHP with the Doctrine ORM",
"description": "This book is designed for PHP developers and architects who want to modernize their skills through better understanding of Persistence and ORM.",
"author": "Kévin Dunglas",
"publicationDate": "2013-12-01"
}
"""
Then the response status code should be 201 # Behat\MinkExtension\Context\MinkContext::assertResponseStatus()
And the response should be in JSON # Sanpi\Behatch\Context\JsonContext::theResponseShouldBeInJson()
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" # Sanpi\Behatch\Context\RestContext::theHeaderShouldBeEqualTo()
And the JSON should be equal to: # Sanpi\Behatch\Context\JsonContext::theJsonShouldBeEqualTo()
"""
{
"@context": "/contexts/Book",
"@id": "/books/1",
"@type": "http://schema.org/Book",
"id": 1,
"isbn": "9781782164104",
"description": "This book is designed for PHP developers and architects who want to modernize their skills through better understanding of Persistence and ORM.",
"author": "K\u00e9vin Dunglas",
"title": "Persistence in PHP with the Doctrine ORM",
"publicationDate": "2013-12-01T00:00:00+00:00"
}
"""
The json is equal to:
{
"@context": "\/contexts\/Book",
"@id": "\/books\/1",
"@type": "http:\/\/schema.org\/Book",
"id": 1,
"isbn": "9781782164104",
"description": "This book is designed for PHP developers and architects who want to modernize their skills through better understanding of Persistence and ORM.",
"author": "K\u00e9vin Dunglas",
"title": "Persistence in PHP with the Doctrine ORM",
"publicationDate": "2013-12-01T00:00:00+01:00"
} (Behat\Mink\Exception\ExpectationException)
Scenario: Retrieve the book list # features/books.feature:39
When I add "Accept" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I send a "GET" request to "/books" # Sanpi\Behatch\Context\RestContext::iSendARequestTo()
Then the response status code should be 200 # Behat\MinkExtension\Context\MinkContext::assertResponseStatus()
And the response should be in JSON # Sanpi\Behatch\Context\JsonContext::theResponseShouldBeInJson()
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" # Sanpi\Behatch\Context\RestContext::theHeaderShouldBeEqualTo()
And the JSON should be equal to: # Sanpi\Behatch\Context\JsonContext::theJsonShouldBeEqualTo()
"""
{
"@context": "/contexts/Book",
"@id": "/books",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/books/1",
"@type": "http://schema.org/Book",
"id": 1,
"isbn": "9781782164104",
"description": "This book is designed for PHP developers and architects who want to modernize their skills through better understanding of Persistence and ORM.",
"author": "K\u00e9vin Dunglas",
"title": "Persistence in PHP with the Doctrine ORM",
"publicationDate": "2013-12-01T00:00:00+00:00"
}
],
"hydra:totalItems": 1
}
"""
The json is equal to:
{
"@context": "\/contexts\/Book",
"@id": "\/books",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "\/books\/1",
"@type": "http:\/\/schema.org\/Book",
"id": 1,
"isbn": "9781782164104",
"description": "This book is designed for PHP developers and architects who want to modernize their skills through better understanding of Persistence and ORM.",
"author": "K\u00e9vin Dunglas",
"title": "Persistence in PHP with the Doctrine ORM",
"publicationDate": "2013-12-01T00:00:00+01:00"
}
],
"hydra:totalItems": 1
} (Behat\Mink\Exception\ExpectationException)
Scenario: Throw errors when a post is invalid # features/books.feature:67
When I add "Content-Type" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I add "Accept" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I send a "POST" request to "/books" with body: # Sanpi\Behatch\Context\RestContext::iSendARequestToWithBody()
"""
{
"isbn": "1312",
"title": "",
"description": "Yo!",
"author": "Me!",
"publicationDate": "2016-01-01"
}
"""
Then the response status code should be 400 # Behat\MinkExtension\Context\MinkContext::assertResponseStatus()
And the response should be in JSON # Sanpi\Behatch\Context\JsonContext::theResponseShouldBeInJson()
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" # Sanpi\Behatch\Context\RestContext::theHeaderShouldBeEqualTo()
And the JSON should be equal to: # Sanpi\Behatch\Context\JsonContext::theJsonShouldBeEqualTo()
"""
{
"@context": "/contexts/ConstraintViolationList",
"@type": "ConstraintViolationList",
"hydra:title": "An error occurred",
"hydra:description": "isbn: This value is neither a valid ISBN-10 nor a valid ISBN-13.\ntitle: This value should not be blank.",
"violations": [
{
"propertyPath": "isbn",
"message": "This value is neither a valid ISBN-10 nor a valid ISBN-13."
},
{
"propertyPath": "title",
"message": "This value should not be blank."
}
]
}
"""
Scenario: Add a review # features/books.feature:103
When I add "Content-Type" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I add "Accept" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I send a "POST" request to "/reviews" with body: # Sanpi\Behatch\Context\RestContext::iSendARequestToWithBody()
"""
{
"rating": 5,
"body": "Must have!",
"author": "Foo Bar",
"publicationDate": "2016-01-01",
"book": "/books/1"
}
"""
Then the response status code should be 201 # Behat\MinkExtension\Context\MinkContext::assertResponseStatus()
And the response should be in JSON # Sanpi\Behatch\Context\JsonContext::theResponseShouldBeInJson()
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" # Sanpi\Behatch\Context\RestContext::theHeaderShouldBeEqualTo()
And the JSON should be equal to: # Sanpi\Behatch\Context\JsonContext::theJsonShouldBeEqualTo()
"""
{
"@context": "/contexts/Review",
"@id": "/reviews/1",
"@type": "http://schema.org/Review",
"id": 1,
"rating": 5,
"body": "Must have!",
"book": "/books/1",
"author": "Foo Bar",
"publicationDate": "2016-01-01T00:00:00+00:00"
}
"""
The json is equal to:
{
"@context": "\/contexts\/Review",
"@id": "\/reviews\/1",
"@type": "http:\/\/schema.org\/Review",
"id": 1,
"rating": 5,
"body": "Must have!",
"book": "\/books\/1",
"author": "Foo Bar",
"publicationDate": "2016-01-01T00:00:00+01:00"
} (Behat\Mink\Exception\ExpectationException)
@dropSchema
Scenario: Get reviews by book # features/books.feature:135
When I add "Accept" header equal to "application/ld+json" # Sanpi\Behatch\Context\RestContext::iAddHeaderEqualTo()
And I send a "GET" request to "/reviews?book=/books/1" # Sanpi\Behatch\Context\RestContext::iSendARequestTo()
Then the response status code should be 200 # Behat\MinkExtension\Context\MinkContext::assertResponseStatus()
And the response should be in JSON # Sanpi\Behatch\Context\JsonContext::theResponseShouldBeInJson()
And the header "Content-Type" should be equal to "application/ld+json; charset=utf-8" # Sanpi\Behatch\Context\RestContext::theHeaderShouldBeEqualTo()
And the JSON should be equal to: # Sanpi\Behatch\Context\JsonContext::theJsonShouldBeEqualTo()
"""
{
"@context": "/contexts/Review",
"@id": "/reviews",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "/reviews/1",
"@type": "http://schema.org/Review",
"id": 1,
"rating": 5,
"body": "Must have!",
"book": "/books/1",
"author": "Foo Bar",
"publicationDate": "2016-01-01T00:00:00+00:00"
}
],
"hydra:totalItems": 1,
"hydra:view": {
"@id": "/reviews?book=%2Fbooks%2F1",
"@type": "hydra:PartialCollectionView"
},
"hydra:search": {
"@type": "hydra:IriTemplate",
"hydra:template": "/reviews{?}",
"hydra:variableRepresentation": "BasicRepresentation",
"hydra:mapping": []
}
}
"""
The json is equal to:
{
"@context": "\/contexts\/Review",
"@id": "\/reviews",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "\/reviews\/1",
"@type": "http:\/\/schema.org\/Review",
"id": 1,
"rating": 5,
"body": "Must have!",
"book": "\/books\/1",
"author": "Foo Bar",
"publicationDate": "2016-01-01T00:00:00+01:00"
}
],
"hydra:totalItems": 1,
"hydra:view": {
"@id": "\/reviews?book=%2Fbooks%2F1",
"@type": "hydra:PartialCollectionView"
},
"hydra:search": {
"@type": "hydra:IriTemplate",
"hydra:template": "\/reviews{?}",
"hydra:variableRepresentation": "BasicRepresentation",
"hydra:mapping": []
}
} (Behat\Mink\Exception\ExpectationException)
--- Failed scenarios:
features/books.feature:8
features/books.feature:39
features/books.feature:103
features/books.feature:135
5 scenarios (1 passed, 4 failed)
33 steps (29 passed, 4 failed)
0m0.82s (29.30Mb)