Skip to content

Instantly share code, notes, and snippets.

View Zayon's full-sized avatar

Pablo Godinez Zayon

  • Evaneos
  • Lyon, France
View GitHub Profile
@Zayon
Zayon / add-products-final
Last active June 6, 2019 15:11
Behat results
fixtures-demo $ vendor/bin/behat --tags="@add-products"
@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
@Zayon
Zayon / AddProductAction.php
Last active January 31, 2019 10:43
AddProductAction - Step 2
<?php
/** .... */
class AddProductAction
{
/** .... */
public function __invoke(Request $request)
{
$payload = json_decode($request->getContent(), true);
$category = $this->productCategoryRepository->find($payload['category']);
@Zayon
Zayon / FeatureContext.php
Last active June 6, 2019 14:33
FeatureContext - Step 1
<?php
declare(strict_types=1);
use Behat\Behat\Context\Context;
use Behat\Symfony2Extension\Context\KernelAwareContext;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
class FeatureContext implements Context, KernelAwareContext
@Zayon
Zayon / RestContext.php
Last active June 6, 2019 15:09
RestContext
<?php
declare(strict_types=1);
use Behat\Gherkin\Node\PyStringNode;
use Behatch\Context\RestContext as BehatchRestContext;
class RestContext extends BehatchRestContext
{
use SharedContextTrait;
@Zayon
Zayon / SharedContextTrait.php
Last active June 6, 2019 15:07
SharingContext - Step 1
<?php
declare(strict_types=1);
use Behat\Behat\Context\Environment\InitializedContextEnvironment;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
trait SharedContextTrait
{
/** @var SharingContext */
@Zayon
Zayon / add-products.feature
Created January 10, 2019 09:56
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
@Zayon
Zayon / AddProductAction.php
Created January 10, 2019 09:34
Fixtures - AddProductAction Step 1
<?php
declare(strict_types=1);
namespace App\Action;
use Symfony\Component\HttpFoundation\Request;
class AddProductAction
{
@Zayon
Zayon / list-product.feature
Created December 31, 2018 16:09
Fixtures - list-product.feature
@product @list-products
Feature:
In order to select products
As a customer
I want to see the products available
Background:
Given the fixtures file "list-products.yaml" is loaded
Scenario: List all products
@Zayon
Zayon / list-products.yaml
Created December 31, 2018 15:05
Fixtures - list-products.yaml
App\Entity\ProductCategory:
category_tools:
name: 'tools'
category_lighting:
name: 'lighting'
App\Entity\Product:
tools_products_{1..10}:
name: '<firstName()>'
@Zayon
Zayon / ListProductsAction.php
Last active December 31, 2018 13:36
Fixtures - ListProductsAction
<?php
namespace App\Action;
// use statements omitted for concision
class ListProductsAction
{
// Properties & constructor omitted for concision
public function __invoke(Request $request): JsonResponse