Skip to content

Instantly share code, notes, and snippets.

@silviuvoicu
silviuvoicu / ReaderController.php
Created September 6, 2013 11:17
specking a registration (createAction) in my controller
<?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 August 23, 2013 16:22
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
<?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 August 20, 2013 07:39
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…
<?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;