Skip to content

Instantly share code, notes, and snippets.

View ftassi's full-sized avatar

Francesco Tassi ftassi

View GitHub Profile
@ftassi
ftassi / FeaturesContext.php
Last active August 29, 2015 14:02
Snippet del post "Da TDD a BDD con Symfony2"
public function cleanDatabase()
{
$container = $this->kernel->getContainer();
$registry = $container->get('doctrine');
$om = $registry->getManager();
$type = 'ORM';
$executorClass = 'Doctrine\\Common\\DataFixtures\\Executor\\' . $type . 'Executor';
$referenceRepository = new ProxyReferenceRepository($om);
@ftassi
ftassi / console-listener.php
Last active August 29, 2015 14:16
Database sharding with doctrine
<?php
public function onConsoleCommand(ConsoleCommandEvent $event)
{
$shardManager = new PoolingShardManager($connection);
$shard = $input->getParameterOption(['--shard', '-s']);
if ('global' === $shard) {
} else {
$shardManager->selectGlobal();
$shardManager->selectShard($shard);
}
@ftassi
ftassi / bookingpage.php
Last active August 29, 2015 14:16
PageObjectExampleImplementation
class BookingPage extends Page
{
public function bookAs($firstName, $lastName, $email)
{
$bookingForm = $this->find('css', 'form#booking-form');
$bookingForm->fillField('booking[firstName]', $firstName);
$bookingForm->fillField('booking[lastName]', $lastName);
$bookingForm->fillField('booking[email]', $email);
}
@ftassi
ftassi / php-cs-fixer-pre-commit.php
Last active September 1, 2015 13:49 — forked from mardix/php-cs-fixer-pre-commit.php
A pre-commit hook to make PHP code PSR-2 compliant, check for syntax error
#!/usr/bin/php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP error (lint), and make sure the code
* is PSR compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*
@ftassi
ftassi / .gitignore
Created September 21, 2010 08:39 — forked from gestadieu/sfWidgetFormChoiceAutocomplete
sfWidgetFormChoiceAutocomplete
.svn
<?php
require_once dirname(__FILE__).'/../../../../../plugins/sfSimplePagePlugin/modules/sfSimplePage/lib/BasesfSimplePageActions.class.php';
/**
* sfSimplePage actions.
*
* @package sfSimplePagePlugin
* @subpackage sfSimplePage
* @author Your name here
@ftassi
ftassi / Shop.class.php
Created December 16, 2010 08:45
hydrate custom data in doctrine object
<?php
/**
* Shop
*
* This class has been auto-generated by the Doctrine ORM Framework
*
* @subpackage model
* @author Your name here
* @version SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
@ftassi
ftassi / BaseFormDoctrine.class.php
Created December 22, 2010 17:06
BaseFormDoctrine con metodi per la configurazione di file uploads
<?php
/**
* Project form base class.
*
* @package versace
* @subpackage form
* @author Your name here
* @version SVN: $Id: sfDoctrineFormBaseTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
@ftassi
ftassi / gist:873338
Created March 16, 2011 21:20
symfony functional test login
//login example1
$browser = new sfTestFunctional(new sfBrowser());
$browser->
get('/yourloginrul')->
click('yourSubmitButton', array('yourLoginFormNameFormat' => array('username' => 'yourUsername', 'password' => 'yourPassword')))->
followRedirect();
//Now you are authenticated
//login example2
//More verbose for debug purpose