Skip to content

Instantly share code, notes, and snippets.

View arnolanglade's full-sized avatar

Arnaud Langlade arnolanglade

View GitHub Profile
<?php
namespace Akeneo\Bundle\ClassificationBundle\Doctrine\ORM\Repository;
use Akeneo\Bundle\StorageUtilsBundle\Doctrine\ORM\Repository\SearchableRepository;
use Akeneo\Component\Classification\Repository\TagRepositoryInterface;
/**
* Tag repository
*
$collection->getIterator()->willReturn($iterator);
$iterator->rewind()->willReturn(null);
$valueCount = 1;
$iterator->valid()->will(
function () use (&$valueCount) {
return $valueCount-- > 0;
}
);
$iterator->current()->willReturn($value);
@arnolanglade
arnolanglade / gist:4ca0bedbcf41356a112a
Last active February 8, 2018 14:26
PhpSpec Symfony command template
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class CommandSpec extends ObjectBehavior
{
function it_has_a_name()
{
$this->getName()->shouldReturn('name:command');
}
@arnolanglade
arnolanglade / gist:3447e85d5e49e22f1066
Created July 8, 2015 11:42
PhpSpec doctrine repository template
// Doctrine ORM
use Doctrine\ORM\Mapping\ClassMetadata;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\AbstractQuery;
use Doctrine\ORM\QueryBuilder;
class RepositorySpec extends ObjectBehavior
{
function let(EntityManager $em, ClassMetadata $classMetadata)
{
@arnolanglade
arnolanglade / gist:abc2013d4bf7f9287713
Last active August 29, 2015 14:24
Basic authentication (Lazy mode : on)
security:
providers:
api_provider:
memory:
users:
user: { password: password, roles: 'ROLE_API' }
encoders:
Symfony\Component\Security\Core\User\User: plaintext
firewalls:
api:
{
"name": "symfony/framework-standard-edition",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.2.*",
"doctrine/orm": "~2.2,>=2.2.3",