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->setTitle('...');
     $node1->setDescription('...');
     $node1->setStatus(true);
     $node1->setMetaUrl($urlText);
     $this->dm->persist($node1);
     $this->dm->flush();
     $this->dm->clear();
     // Create Page Node 2
     $node2 = new Node();
     $node2->setLocale('en');
     $node2->setTitle('...');
     $node2->setDescription('...');
     $node2->setStatus(true);
     $node2->setMetaUrl($urlText);
     $this->dm->persist($node2);
     $this->dm->flush();
     // Delete Page Node 1
     $node1 = $this->dm->getRepository('Aisel\\PageBundle\\Document\\Node')->findOneBy(['metaUrl' => $urlText]);
     $this->dm->remove($node1);
     $this->dm->flush();
     $this->dm->clear();
 }
Exemplo n.º 2
0
 public function testDuplicateNodes()
 {
     $node = new Node();
     $node->setStatus(true);
     $node->setDescription($this->faker->sentence(10));
     $node->setMetaUrl('url_' . time());
     $node->setLocale('en');
     $this->dm->persist($node);
     $this->dm->flush();
     $this->assertNotNull($node->getId());
     $page = new Page();
     $page->setLocale('en');
     $page->setTitle($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->dm->persist($page);
     $this->dm->flush();
     $this->assertNotNull($page->getId());
     $this->assertEquals(count($page->getNodes()), 1);
     $this->dm->remove($node);
     $this->dm->flush();
     $this->dm->remove($page);
     $this->dm->flush();
 }
Exemplo n.º 3
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[2] != 'NULL') {
                     $parent = $this->getReference('page_node_' . $table->column[2]);
                 }
                 $node = new Node();
                 $node->setLocale($table->column[1]);
                 $node->setTitle($table->column[3]);
                 $node->setDescription($table->column[8]);
                 $node->setStatus((int) $table->column[9]);
                 $node->setMetaUrl($table->column[10]);
                 if ($parent) {
                     $node->setParent($parent);
                 }
                 $manager->persist($node);
                 $manager->flush();
                 $this->addReference('page_node_' . $table->column[0], $node);
             }
         }
     }
 }