Skip to content

Instantly share code, notes, and snippets.

@Zayon
Created January 10, 2019 09:56
Show Gist options
  • Save Zayon/8079f7068bafa52f838e21513b6dc3b4 to your computer and use it in GitHub Desktop.
Save Zayon/8079f7068bafa52f838e21513b6dc3b4 to your computer and use it in GitHub Desktop.
Fixtures - add-products step 1
@product @add-products
Feature:
In order to offer a large choice of products
As a product seller
I want to add products
Background:
Given the fixtures file "add-products.yaml" is loaded
Scenario: Add a product
Given I send a "GET" request to "/products/"
And the response status code should be 200
And the JSON node "total" should be equal to the number 5
When I send a "POST" request to "/products/" with body:
"""
{
"name": "Super cool drill",
"price": 249.99,
"category": 1
}
"""
Then the response status code should be 200
And I send a "GET" request to "/products/"
And the JSON node "total" should be equal to the number 6
App\Entity\ProductCategory:
category_tools:
name: 'tools'
App\Entity\Product:
tools_products_{1..5}:
name: '<firstName()>'
category: '@category_tools' # reference to "category_tools" fixture
price: '<randomFloat(2, 10.00, 1000.00)>' # random price from 10 to 1000 euros
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment