Skip to content

Instantly share code, notes, and snippets.

@silviuvoicu
silviuvoicu / ReaderController.php
Created Sep 6, 2013
specking a registration (createAction) in my controller
View ReaderController.php
<?php
namespace BddSBP\ReaderBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
@silviuvoicu
silviuvoicu / ReaderControllerSpec.php
Created Aug 23, 2013
a new version of specking the symfony controller of new action(just rendering the form, or in my case just return an array with the form) when no entity or form doesn't exist, yet. with this version, phpspec offer to create my entity and my form, of course just simple classes
View ReaderControllerSpec.php
<?php
namespace spec\BddSBP\ReaderBundle\Controller;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Symfony\Component\DependencyInjection\Container;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\EntityManager;
@silviuvoicu
silviuvoicu / BookController.php
Created Aug 20, 2013
Spec with phpspec a symfony2 controller. I know which is the normal work flow: write first the spec, and then the code, but in order to understand better how to spec a symfony2 controller, I first create a simple book entity with just id and name, and then with the help of generators I created a crud system, which I modified a little. Then havin…
View BookController.php
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Acme\DemoBundle\Entity\Book;