我在执行每个测试之前使用DoctrineFixturesBundle创建测试记录。但它在我的数据库中造成了混乱,因此我想在每次测试完成后删除这些添加的记录。如何在不删除整个数据库的情况下执行此操作?
/**
* 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();
}