*/ abstract class ContainerAwareTestCase extends \PHPUnit_Framework_TestCase { protected $import; /** @var ContainerInterface */ protected $container; /** @var Session */ protected $session; public function getContainer() { $container = new ContainerBuilder(); $container->set("thelia.translator", new Translator(new Container())); $dispatcher = $this->getMockEventDispatcher(); $container->set("event_dispatcher", $dispatcher); $request = new Request(); $request->setSession($this->getSession()); $container->set("request", $request); $requestStack = new RequestStack(); $requestStack->push($request); $container->set("request_stack", $requestStack); new Translator($container); $container->set("thelia.securitycontext", new SecurityContext($requestStack)); $this->buildContainer($container); return $container; } public function getSession() { return new Session(new MockArraySessionStorage()); } public function setUp() { Tlog::getNewInstance(); $this->session = $this->getSession(); $this->container = $this->getContainer(); } /** * @param ContainerBuilder $container * Use this method to build the container with the services that you need. */ abstract protected function buildContainer(ContainerBuilder $container); /** * @return EventDispatcherInterface */ protected function getMockEventDispatcher() { return $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); } /** * @return KernelInterface */ public function getKernel() { $kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface"); return $kernel; } }