daily pastebin goal
73%
SHARE
TWEET

BaseTestCase - Clase Base para Test en PHPUnit

gorkamu Apr 26th, 2015 241 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3.  * Created by JetBrains PhpStorm.
  4.  * User: gorka
  5.  * Date: 3/01/14
  6.  * Time: 7:24
  7.  */
  8. namespace Modelo\BLBundle\Tests\Controller;
  9.  
  10. use Util\Constantes;
  11.  
  12. require_once Constantes::ABSOLUTE_PATH_APPKERNEL_TEST;
  13.  
  14. /**
  15.  * Class BaseTestCase
  16.  * @package Modelo\BLBundle\Tests\Controller
  17.  */
  18. class BaseTestCase extends \PHPUnit_Framework_TestCase
  19. {
  20.  
  21.     private $container;
  22.     private $app;
  23.     private $em;
  24.  
  25.     /**
  26.      * Function setUp
  27.      */
  28.     public function setUp()
  29.     {
  30.         $this->app = new \AppKernel('test', false);
  31.         $this->app->boot();
  32.         $this->container = $this->app->getContainer();
  33.         $this->em = $this->container->get('doctrine')->getManager();
  34.         $this->em->getConnection()->beginTransaction();
  35.         parent::setUp();
  36.     }
  37.  
  38.  
  39.     /**
  40.      * Function tearDown
  41.      */
  42.     public function tearDown()
  43.     {
  44.         $this->app->shutdown();
  45.         $this->em->getConnection()->rollback();
  46.         parent::tearDown();
  47.     }
  48.  
  49.  
  50.     /**
  51.      * Function getContainer
  52.      * </br>
  53.      *
  54.      * @return mixed
  55.      */
  56.     public function getContainer()
  57.     {
  58.         return $this->container;
  59.     }
  60.  
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top