/** * {@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() { $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(); }
public function testDuplicatedUrlThrowsError() { $urlText = 'page-test-meta-url'; $this->setExpectedException('LogicException', 'Given URL already exists'); // Create Page 1 $page1 = new Page(); $page1->setLocale('en'); $page1->setContent('...'); $page1->setName('...'); $page1->setStatus(true); $page1->setMetaUrl($urlText); $page1->setMetaTitle('...'); $page1->setCommentStatus(true); $this->em->persist($page1); $this->em->flush(); $this->em->clear(); // Create Page 2 $page2 = new Page(); $page2->setLocale('en'); $page2->setContent('...'); $page2->setName('...'); $page2->setStatus(true); $page2->setMetaUrl($urlText); $page2->setMetaTitle('...'); $page2->setCommentStatus(true); $this->em->persist($page2); $this->em->flush(); // Delete Page 1 $page1 = $this->em->getRepository('Aisel\\PageBundle\\Entity\\Page')->findOneBy(['metaUrl' => $urlText]); $this->em->remove($page1); $this->em->flush(); $this->em->clear(); }
/** * newPage * * @return Page $page */ public function newPage() { $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_' . $this->faker->numberBetween(100000000, 9999999999)); $this->em->persist($page); $this->em->flush(); return $page; }
/** * newPage * * @return Page $page */ public function newPage() { $user = $this->em->getRepository('Aisel\\UserBundle\\Entity\\User')->findOneBy(['email' => '*****@*****.**']); $page = new Page(); $page->setLocale('en'); $page->setUser($user); $page->setName($this->faker->sentence(1)); $page->setContent($this->faker->sentence(10)); $page->setStatus(true); $page->setCommentStatus(true); $page->setMetaUrl('url_' . $this->faker->numberBetween(100000000, 9999999999)); $this->em->persist($page); $this->em->flush(); return $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(); }