public function testPurge() { $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures'); $loader->loadFixtures(); $loader->purgeDatabase('mongodb'); $cars = $this->doctrine->getManager()->getRepository('Khepin\\Fixture\\Document\\Car')->findAll(); $this->assertEquals(count($cars), 0); $drivers = $this->doctrine->getManager()->getRepository('Khepin\\Fixture\\Document\\Driver')->findAll(); $this->assertEquals(count($drivers), 0); }
public function testPurge() { $this->kernel = m::mock('AppKernel', array('locateResource' => __DIR__ . '/simple_loading/')); $loader = new YamlLoader($this->kernel, $this->doctrine, array('SomeBundle')); $loader->loadFixtures('with_drivers'); $loader->purgeDatabase(); $cars = $this->doctrine->getEntityManager()->getRepository('Khepin\\Fixture\\Entity\\Car')->findAll(); $this->assertEmpty($cars); $drivers = $this->doctrine->getEntityManager()->getRepository('Khepin\\Fixture\\Entity\\Driver')->findAll(); $this->assertEmpty($drivers); }
public function testPurgeWithTruncate() { $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures'); $loader->loadFixtures('with_drivers'); $cars = $this->doctrine->getEntityManager()->getRepository('Khepin\\Fixture\\Entity\\Car')->findAll(); $firstCar = $cars[0]; $firstCarIdBefore = $firstCar->getId(); $loader->purgeDatabase('orm', null, true); $cars = $this->doctrine->getEntityManager()->getRepository('Khepin\\Fixture\\Entity\\Car')->findAll(); $this->assertEmpty($cars); $loader->loadFixtures('with_drivers'); $cars = $this->doctrine->getEntityManager()->getRepository('Khepin\\Fixture\\Entity\\Car')->findAll(); $firstCar = $cars[0]; $firstCarIdAfter = $firstCar->getId(); $this->assertEquals($firstCarIdBefore, $firstCarIdAfter); }