Example #1
0
 /**
  * {@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) {
                 $parent = null;
                 if ($table->column[3] != 'NULL') {
                     $parent = $this->getReference('page_node_' . $table->column[3]);
                 }
                 $node = new Node();
                 $node->setLocale($table->column[2]);
                 $node->setName($table->column[4]);
                 $node->setContent($table->column[9]);
                 $node->setStatus((int) $table->column[10]);
                 $node->setMetaUrl($table->column[11]);
                 if ($parent) {
                     $node->setParent($parent);
                 }
                 $manager->persist($node);
                 $manager->flush();
                 $this->addReference('page_node_' . $table->column[0], $node);
             }
         }
     }
 }
Example #2
0
 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-node-test-meta-url';
     $this->setExpectedException('LogicException', 'Given URL already exists');
     // Create Page Node 1
     $node1 = new Node();
     $node1->setLocale('en');
     $node1->setName('...');
     $node1->setContent('...');
     $node1->setStatus(true);
     $node1->setMetaUrl($urlText);
     $this->em->persist($node1);
     $this->em->flush();
     $this->em->clear();
     // Create Page Node 2
     $node2 = new Node();
     $node2->setLocale('en');
     $node2->setName('...');
     $node2->setContent('...');
     $node2->setStatus(true);
     $node2->setMetaUrl($urlText);
     $this->em->persist($node2);
     $this->em->flush();
     // Delete Page Node 1
     $node1 = $this->em->getRepository('Aisel\\PageBundle\\Entity\\Node')->findOneBy(['metaUrl' => $urlText]);
     $this->em->remove($node1);
     $this->em->flush();
     $this->em->clear();
 }
Example #4
0
 /**
  * newNode
  *
  * @return Node $node
  */
 public function newNode()
 {
     $node = new Node();
     $node->setName($this->faker->sentence());
     $node->setStatus(true);
     $node->setLocale('en');
     $node->setMetaUrl($this->faker->sentence());
     $this->em->persist($node);
     $this->em->flush();
     return $node;
 }
Example #5
0
 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();
 }