Skip to content

Instantly share code, notes, and snippets.

View gnugat's full-sized avatar
💭
Test, Code, Refactor, Repeat!

Loïc Faugeron gnugat

💭
Test, Code, Refactor, Repeat!
View GitHub Profile
@gnugat
gnugat / StackRollback.php
Last active May 12, 2017 09:24
A Middleware preventing Doctrine DBAL to change the database, useful for tests
<?php
namespace Gnugat\StackRollback;
use Doctrine\DBAL\Connection;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* Example:
<?php
// File: app/config/importer.php
use Symfony\Component\Finder\Finder;
$finder = new Finder();
$files = $finder->files()->name('*.yml')->in(__DIR__.'/services')->in(__DIR__.'/vendors');
foreach ($files as $file) {
$loader->import($file->getRealpath());
}
@gnugat
gnugat / command_with_defaults.php
Created September 27, 2015 15:20
An example of a Command (from CommandBus), with default values
<?php
use Assert\Assertion;
class RegisterNewMember
{
public $email;
public $subscribeToNewsletter = true;
public function __construct($email, $subscribeToNewsletter = null)