public function testDuplicateNodes() { $user = $this->em->getRepository('Aisel\\UserBundle\\Entity\\User')->findOneBy(['email' => '*****@*****.**']); $this->setExpectedException('Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException'); $node = new Node(); $node->setName($this->faker->title); $node->setStatus(true); $node->setContent($this->faker->sentence(10)); $node->setMetaUrl('url_' . time()); $node->setLocale('en'); $this->em->persist($node); $this->em->flush(); $this->assertNotNull($node->getId()); $page = new Page(); $page->setUser($user); $page->setLocale('en'); $page->setName($this->faker->sentence(1)); $page->setContent($this->faker->sentence(10)); $page->setStatus(true); $page->setCommentStatus(true); $page->setMetaUrl('url_' . time()); $page->addNode($node); $page->addNode($node); $this->em->persist($page); $this->em->flush(); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { foreach ($this->fixtureFiles as $file) { if (file_exists($file)) { $contents = file_get_contents($file); $XML = simplexml_load_string($contents); foreach ($XML->database->table as $table) { $page = new Page(); $page->setLocale($table->column[1]); $page->setName($table->column[2]); $page->setContent($table->column[3]); $page->setStatus($table->column[4]); $page->setCommentStatus($table->column[6]); $page->setMetaUrl($table->column[7]); $nodes = explode(",", $table->column[8]); foreach ($nodes as $c) { $node = $this->getReference('page_node_' . $c); $page->addNode($node); } $manager->persist($page); $manager->flush(); $this->addReference('page_' . $table->column[0], $page); } } } }
public function testDuplicateNodes() { $this->setExpectedException('Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException'); $node = new Node(); $node->setName($this->faker->title); $node->setStatus(true); $node->setContent($this->faker->sentence(10)); $node->setMetaUrl('url_' . time()); $node->setLocale('en'); $this->em->persist($node); $this->em->flush(); $this->assertNotNull($node->getId()); $page = new Page(); $page->setLocale('en'); $page->setName($this->faker->sentence(1)); $page->setContent($this->faker->sentence(10)); $page->setStatus(true); $page->setCommentStatus(true); $page->setMetaUrl('url_' . time()); $page->addNode($node); $page->addNode($node); $this->em->persist($page); $this->em->flush(); }