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 / pre-commit
Created October 25, 2017 14:19
pre-commit php-cs-fixer
#!/usr/bin/env bash
ROOT=$(git rev-parse --show-toplevel)
cd "$ROOT"
git --git-dir "$ROOT"/.git --work-tree "$ROOT" status --porcelain | grep -e '^[AM]\(.*\).php$' | cut -c 3- | while read line; do
bin/php-cs-fixer fix --dry-run --diff --no-ansi --verbose "$line"
if [ $? -ne 0 ]; then
exit 1
fi
@Zayon
Zayon / solutions.md
Last active February 16, 2018 14:37
@Zayon
Zayon / shortlist
Last active April 10, 2018 13:02
PHP backslash function shortlist
"array_slice"
"assert"
"boolval"
"call_user_func"
"call_user_func_array"
"chr"
"count"
"defined"
"doubleval"
"floatval"
@Zayon
Zayon / Step1-FixtureContext.php
Last active November 11, 2018 19:07
Fixtures in Symfony 4
<?php
declare(strict_types=1);
use Behat\Behat\Context\Context;
class FixtureContext implements Context
{
// Empty for now
}
@Zayon
Zayon / FixtureContext.php
Created November 23, 2018 15:21
Step 1 - FixtureContext.php
<?php
declare(strict_types=1);
use Behat\Behat\Context\Context;
class FixtureContext implements Context
{
// Empty for now
}
@Zayon
Zayon / FixtureContext.php
Last active November 23, 2018 17:07
Step 2 - FixtureContext
<?php
declare(strict_types=1);
use Behat\Behat\Context\Context;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Fidry\AliceDataFixtures\LoaderInterface;
class FixtureContext implements Context
{
@Zayon
Zayon / Product.php
Created December 31, 2018 13:27
Fixtures - Entities
<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProductRepository")
*/
class Product
@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
@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 / 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