Skip to content

Instantly share code, notes, and snippets.

Avatar
🐼
Yay

Ludovic Fleury ludofleury

🐼
Yay
View GitHub Profile
@ludofleury
ludofleury / StockValidator.php
Last active Dec 15, 2015
atoum mock example
View StockValidator.php
<?php
namespace MyLittle\Bundle\BoxBundle\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Doctrine\Common\Persistence\ManagerRegistry;
use MyLittle\Bundle\BoxBundle\Model\ProductInterface;
use DomainException;
use InvalidArgumentException;
@ludofleury
ludofleury / atoum-is-awesome.php
Created Mar 8, 2013
The power of atoum, everything in my job should be so simple.
View atoum-is-awesome.php
<?php
public function testAddBox()
{
$package = new Entity\Package();
$box = new \Mock\MyLittle\Bundle\BoxBundle\Entity\Box;
$this
->object($package->addBox($box))
->isIdenticalTo($package)
@ludofleury
ludofleury / MysqlContext.php
Last active Mar 20, 2020
A Behat Context with a hook to kill the Mysql connections
View MysqlContext.php
<?php
use Behat\Symfony2Extension\Context\KernelAwareInterface;
use Behat\Symfony2Extension\Context\KernelDictionary;
use Behat\MinkExtension\Context\MinkContext;
class MysqlContext extends MinkContext implements KernelAwareInterface
{
use KernelDictionary;
@ludofleury
ludofleury / getset.sublime-snippet
Created Feb 15, 2013
PHP (Symfony) oriented getter-setter snippet for Sublime Text
View getset.sublime-snippet
<snippet>
<content><![CDATA[
/**
* Get $1
*
* @return ${2:[type]} \$$1
*/
public function get${1/(.*)/\u$1/}()
{
return \$this->${1:$SELECTION};
View amqp_nack.php
<?php
include(__DIR__ . '/config.php');
use PhpAmqpLib\Connection\AMQPConnection;
$exchange = 'router';
$queue = 'msgs';
$consumer_tag = 'consumer';
$conn = new AMQPConnection(HOST, PORT, USER, PASS, VHOST);
@ludofleury
ludofleury / app_test.php
Created Sep 8, 2012
Swiftmailer redirecting plugin in Silex
View app_test.php
<?php
$app['mailer'] = $app->share(function ($app) {
$app['mailer.initialized'] = true;
return new \Swift_Mailer($app['swiftmailer.transport']);
});
$app['mailer']->registerPlugin(new \Swift_Plugins_RedirectingPlugin($config['swiftmailer']['delivery_address'], array('#^'.$config['swiftmailer']['delivery_address'].'$#')));
View 1-hack-header.php
// because php sucks at providing custom headers...
$headers = apache_request_headers();
if (isset($headers['Authorization'])) {
$this->headers->set('Authorization', $headers['Authorization']);
}
View PropelUniqueObject.php
<?php
/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
View controllers.php
<?php
$controllers->post('/{myModel}/items', function (Model\myModel $myModel, Request $request) use ($app) {
//...
)}
->bind('mymodel_create')
->accept('url-encode')
->accept('json')
->contentType('kutio+xml', array('*/*', 'application/*', 'application/vnd.kutio+xml'))
->contentType('json', array('application/json', 'application/x-json'))
View atoum.log
[15:46] == Ludof [513967f0@gateway/web/freenode/ip.81.57.103.240] has joined ##atoum
[15:46] -ChanServ- [##atoum] Welcome on channel of atoum, the simple, modern and intuitive unit test framework for PHP 5.3+ !
[15:46] <Ludof> Hello les gens
[15:46] <Ludof> si y'a du atoum boyz dans la salle, j'voudrais rapidement comprendre le coup du if(),and(),then() sur atoum, c'est le truc que j'ai pas suivi.
[15:46] == jubianchi[work] [~ABC-OBJEC@92.103.14.114] has quit [Read error: No route to host]
[15:47] <Ludof> genre typiquement: https://github.com/mageekguy/atoum/pull/108/files
[15:47] == jubianchi[work] [~ABC-OBJEC@92.103.14.114] has joined ##atoum
[16:07] <steph_py> Yop Ludof
[16:07] <steph_py> J'ai pas trop touché à cette fonctionnalité
[16:07] <steph_py> mais visiblement ça permet d'initialiser le contexte
You can’t perform that action at this time.