dimanche 21 décembre 2014

How to purge added records with doctrine fixtures

I'm using DoctrineFixturesBundle to create test records before each test is executed. But it created a mess in my database, so I want to remove those added records after each test is finished. How can I do this without removing the whole database?



/**
* Function initializing test environment
*/
protected function setUp()
{
//
// set the client object for easier access (and cleaner code)
//
$this->client = static::createClient();

//
// create database fixtures
//
$container = $this->client->getContainer();
$doctrine = $container->get('doctrine');
$entityManager = $doctrine->getManager();

$userFixture = new LoadUsersData();
$userFixture->load($entityManager);
}

/**
* Function that runs when the testing is finished
*/
public function tearDown()
{
parent::tearDown();

//
// purge database fixtures
//


//
// close database connection
//
$this->em->close();
}

Aucun commentaire:

Enregistrer un commentaire