public function setUp()
 {
     parent::setUp();
     $kernel = static::createKernel();
     $kernel->boot();
     $this->dm = $kernel->getContainer()->get('doctrine_mongodb')->getManager();
 }
Example #2
0
 protected function setUp()
 {
     if (!class_exists('Twig_Environment')) {
         $this->markTestSkipped('Twig is not available.');
     }
     parent::setUp();
 }
 protected function setUp()
 {
     parent::setUp();
     self::$kernel = static::createKernel();
     self::$kernel->boot();
     $this->entityManager = self::$kernel->getContainer()->get('doctrine')->getManager();
 }
 protected static function createPersistentClient($cookieName = 'test')
 {
     $client = parent::createClient();
     $client->getContainer()->get('session.storage.file')->deleteFile();
     $client->getCookieJar()->set(new Cookie(session_name(), $cookieName));
     return $client;
 }
 /**
  * @inheritdoc
  */
 protected function setUp()
 {
     parent::setUp();
     $this->client = $this->createClient(['debug' => false]);
     $container = static::$kernel->getContainer();
     /** @var EntityManagerInterface[] $managers */
     $managers = $container->get('doctrine')->getManagers();
     foreach ($managers as $manager) {
         $metadata = $manager->getMetadataFactory()->getAllMetadata();
         if (!empty($metadata)) {
             $tool = new SchemaTool($manager);
             $tool->dropSchema($metadata);
             $tool->createSchema($metadata);
         }
     }
     $class = $container->getParameter('tree_house.keystone.model.user.class');
     $salt = uniqid();
     /** @var UserInterface $user */
     $user = new $class();
     $user->setEnabled(true);
     $user->setUsername('test');
     $user->addRole('ROLE_USER');
     $user->setSalt($salt);
     /** @var EncoderFactoryInterface $encoder */
     $encoder = $container->get('security.encoder_factory');
     $password = $encoder->getEncoder($class)->encodePassword(static::$password, $user->getSalt());
     $user->setPassword($password);
     /** @var ManagerRegistry $doctrine */
     $doctrine = static::$kernel->getContainer()->get('doctrine');
     $manager = $doctrine->getManagerForClass($class);
     $manager->persist($user);
     $manager->flush($user);
     $manager->refresh($user);
     $this->user = $user;
 }
 /**
  * Creates a Client.
  *
  * @param array $options An array of options to pass to the createKernel class
  * @param array $server  An array of server parameters
  *
  * @return Client A Client instance
  */
 protected static function createClient(array $options = array(), array $server = array())
 {
     if (!self::$internalClient) {
         self::$internalClient = parent::createClient($options, $server);
         if (self::$db_isolation) {
             /** @var Client $client */
             $client = self::$internalClient;
             //workaround MyISAM search tables are not on transaction
             if (self::$db_reindex) {
                 $kernel = $client->getKernel();
                 $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
                 $application->setAutoExit(false);
                 $options = array('command' => 'oro:search:reindex');
                 $options['--env'] = "test";
                 $options['--quiet'] = null;
                 $application->run(new \Symfony\Component\Console\Input\ArrayInput($options));
             }
             $client->startTransaction();
             $pdoConnection = Client::getPdoConnection();
             if ($pdoConnection) {
                 //set transaction level to 1 for entityManager
                 $connection = $client->createConnection($pdoConnection);
                 $client->getContainer()->set('doctrine.dbal.default_connection', $connection);
                 /** @var EntityManager $entityManager */
                 $entityManager = $client->getContainer()->get('doctrine.orm.entity_manager');
                 if (spl_object_hash($entityManager->getConnection()) != spl_object_hash($connection)) {
                     $reflection = new \ReflectionProperty('Doctrine\\ORM\\EntityManager', 'conn');
                     $reflection->setAccessible(true);
                     $reflection->setValue($entityManager, $connection);
                 }
             }
         }
     }
     return self::$internalClient;
 }
Example #7
0
 public function setUp()
 {
     parent::setUp();
     $this->client = $this->createClient();
     $this->doctrine = $this->client->getContainer()->get('doctrine.orm.entity_manager');
     $this->fixturize($this->doctrine);
 }
 protected function setUp()
 {
     parent::setUp();
     if (version_compare(Kernel::VERSION, '2.2.0', '<')) {
         $this->markTestSkipped('Does not work with Symfony2 2.1 due to a "host" parameter in the `routing.yml` file');
     }
 }
 public function tearDown()
 {
     if ($this->container !== null) {
         $this->container->get('doctrine')->getConnection()->close();
     }
     parent::tearDown();
 }
 /**
  * {@inheritDoc}
  */
 protected function tearDown()
 {
     parent::tearDown();
     if ($this->em instanceof \Doctrine\ORM\EntityManager) {
         $this->em->close();
     }
 }
 /**
  * Setup test.
  *  @return null
  */
 public function setUp()
 {
     $this->app = new \AppKernel('test', true);
     $this->app->boot();
     $this->container = $this->app->getContainer();
     parent::setUp();
 }
 public static function setUpBeforeClass()
 {
     self::$client = static::createClient();
     self::$router = self::$kernel->getContainer()->get('router');
     self::$rootDir = self::$kernel->getContainer()->getParameter('kernel.root_dir');
     parent::setUpBeforeClass();
 }
 protected function tearDown()
 {
     parent::tearDown();
     foreach (glob($this->webDir . '/*{.xml,.xml.gz}', GLOB_BRACE) as $file) {
         unlink($file);
     }
 }
 protected function tearDown()
 {
     $this->truncateTables();
     $this->nullifyProperties();
     parent::tearDown();
     static::$kernel = null;
 }
Example #15
0
 /**
  * {@inheritDoc}
  */
 protected function tearDown()
 {
     parent::tearDown();
     if ($this->em) {
         $this->em->close();
     }
 }
 /**
  * Cleans up the environment after running a test.
  */
 protected function tearDown()
 {
     $this->ipBannedRepository = null;
     $this->ipBanned = null;
     $this->em = null;
     parent::tearDown();
 }
 public function __construct()
 {
     $kernel = new \AppKernel('test', true);
     $kernel->boot();
     $this->_container = $kernel->getContainer();
     parent::__construct();
 }
 protected function tearDown()
 {
     //Close & unsets
     if (is_object($this->em)) {
         $this->em->getConnection()->close();
         $this->em->close();
     }
     unset($this->em);
     unset($this->container);
     unset($this->kern);
     unset($this->client);
     //Nettoyage des mocks
     //http://kriswallsmith.net/post/18029585104/faster-phpunit
     $refl = new \ReflectionObject($this);
     foreach ($refl->getProperties() as $prop) {
         if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
             $prop->setAccessible(true);
             $prop->setValue($this, null);
         }
     }
     //Nettoyage du garbage
     if (!gc_enabled()) {
         gc_enable();
     }
     gc_collect_cycles();
     //Parent
     parent::tearDown();
 }
 /**
  * __construct function.
  * 
  * @access public
  * @param mixed $name (default: null)
  * @return void
  */
 public function __construct($name = null)
 {
     parent::__construct($name);
     static::$kernel = static::createKernel();
     static::$kernel->boot();
     static::$container = static::$kernel->getContainer();
 }
 protected function getCommand()
 {
     $kernel = WebTestCase::createKernel();
     $application = new Application($kernel);
     $adapter = new SymfonyFinder();
     $application->add(new FindCommand($adapter));
     return $application->find('fsearch:find');
 }
Example #21
0
 public static function assertSame($var1, $var2, $message = '')
 {
     parent::assertSame($var1, $var2, $message);
     // assertEquals() throws an exception if not true, so the following
     // won't occur unless the messages actually are the same
     $success = print_r($var1, true) . ' is the same as ' . print_r($var2, true);
     self::$messages = array_merge(self::$messages, array($success));
 }
 protected function getArrayFromMessageBundle($bundle, $locate)
 {
     $client = parent::createClient();
     $kernel = $client->getKernel();
     $foundBundle = $kernel->getBundle($bundle);
     $bundleTransPath = $foundBundle->getPath() . '/Resources/translations';
     return $array = Yaml::parse($bundleTransPath . '/messages.' . $locate . '.yml');
 }
Example #23
0
 public function setUp()
 {
     parent::setUp();
     /** @var \Symfony\Bundle\FrameworkBundle\Client client */
     $this->client = static::createClient();
     $this->runCommand('doctrine:database:create');
     $this->runCommand('doctrine:schema:update --force');
 }
 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->newClient();
     $this->prepareDatabase();
     $this->prepareFactories();
     $this->prepareTest();
 }
 public function tearDown()
 {
     NullPersister::$incrementTotalAccessCalled = false;
     NullPersister::$incrementRepositoryAccessCalled = false;
     NullPersister::$addRepositoryToLatestAccessedCalled = false;
     NullPersister::$incrementRepositoryAccessTypeCalled = false;
     parent::tearDown();
 }
Example #26
0
 protected function runTest()
 {
     if (\PhpSpock\Adapter\PhpUnitAdapter::isSpecification($this)) {
         return \PhpSpock\Adapter\PhpUnitAdapter::runTest($this);
     } else {
         return parent::runTest();
     }
 }
Example #27
0
 /**
  * {@inheritDoc}
  *
  * This is overriden to set the default environment to 'rctest'
  */
 protected static function createKernel(array $options = array())
 {
     // default environment is 'rctest'
     if (!isset($options['environment'])) {
         $options['environment'] = 'default.yml';
     }
     return parent::createKernel($options);
 }
Example #28
0
 public function setUp()
 {
     parent::setUp();
     $this->client = static::createClient();
     $this->client->restart();
     if ($this->logger === null) {
         $this->logger = $this->client->getContainer()->get('monolog.logger.devel');
     }
 }
 public function tearDown()
 {
     foreach ($this->client->getContainer()->getMockedServices() as $id => $service) {
         $this->client->getContainer()->unmock($id);
     }
     \Mockery::close();
     $this->client = null;
     parent::tearDown();
 }
Example #30
0
 public function setUp()
 {
     self::bootKernel();
     parent::setUp();
     $gatewayClassname = 'AppBundle\\Entity\\JokeGateway';
     $this->gateway = $this->prophesize($gatewayClassname);
     $this->factory = new JokeFactory();
     $this->repository = new JokeRepository($this->gateway->reveal(), $this->factory);
 }