Skip to content

Instantly share code, notes, and snippets.

@tspycher
Created February 6, 2014 15:08
Show Gist options
  • Save tspycher/8845944 to your computer and use it in GitHub Desktop.
Save tspycher/8845944 to your computer and use it in GitHub Desktop.
Base Clase wich drops all Collections and build the them from scratch
<?php
namespace XXX\Tests\Document;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
abstract class AbstractTest extends WebTestCase
{
static $container;
static $application;
protected function loadDm($manager = "default", $clear = true) {
$this->dm = self::$container->get('doctrine_mongodb')->getManager($manager);
if ($this->dm and $clear) {
$this->dm->getSchemaManager()->dropCollections();
$this->dm->getSchemaManager()->ensureIndexes();
}
}
public static function setUpBeforeClass()
{
//start the symfony kernel
$kernel = static::createKernel();
$kernel->boot();
//get the DI container
self::$container = $kernel->getContainer();
self::$application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
self::$application->setAutoExit(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment