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 testConstructor() { $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures'); $loader->loadFixtures('construct'); $repo = $this->doctrine->getManager()->getRepository('Khepin\\Fixture\\Entity\\Car'); $car = $repo->findOneByName('Ford'); $this->assertEquals('Ford', $car->getName()); $this->assertInstanceOf('\\DateTime', $car->getDatePurchased()); $repo = $this->doctrine->getManager()->getRepository('Khepin\\Fixture\\Entity\\Owner'); $owner = $repo->findOneByName('Some Small Company'); $this->assertEquals(1, count($owner->getOwnedCars())); $this->assertEquals('Some Small Company', $owner->getName()); }
public function testEmbedMany() { $loader = new YamlLoader($this->kernel, array('SomeBundle'), 'DataFixtures'); $loader->loadFixtures('embed_many'); $repo = $this->doctrine->getManager()->getRepository('Khepin\\Fixture\\Document\\Article'); $articles = $repo->createQueryBuilder()->getQuery()->execute(); $this->assertEquals($articles->count(), 1); $article = $articles->getNext(); $this->assertInstanceOf('Khepin\\Fixture\\Document\\Article', $article); $tags = $article->getTags(); $this->assertEquals('YAML', $tags[0]->getName()); $this->assertEquals($tags->count(), 2); }