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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / doctrine.yaml
Created June 27, 2019 15:30
fixtures-blog-post-config/packages/test/doctrine.yaml
doctrine:
dbal:
driver: pdo_sqlite
url: 'sqlite:'
path: "%kernel.cache_dir%/test_db.sqlite"
@Zayon
Zayon / doctrine.yaml
Created June 27, 2019 15:31
fixtures-blog-post-config/packages/test/doctrine.yaml multiple connections
doctrine:
dbal:
connections:
default_connection: default
# Override each connection
default:
driver: pdo_sqlite
url: 'sqlite:'
path: "%kernel.cache_dir%/test_db.sqlite"
@Zayon
Zayon / FixtureContext.php
Created June 27, 2019 15:33
fixtures-blog-post schemaTool
<?php
$schemaTool = new SchemaTool($manager);
$schemaTool->dropDatabase();
$schemaTool->createSchema($manager->getMetadataFactory()->getAllMetadata());