/**
  * {@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_category_' . $table->column[2]);
                 }
                 $category = new Category();
                 $category->setLocale($table->column[1]);
                 $category->setTitle($table->column[3]);
                 $category->setDescription($table->column[8]);
                 $category->setStatus((int) $table->column[9]);
                 $category->setMetaUrl($table->column[10]);
                 if ($parent) {
                     $category->setParent($parent);
                 }
                 $manager->persist($category);
                 $manager->flush();
                 $this->addReference('page_category_' . $table->column[0], $category);
             }
         }
     }
 }
 public function testDuplicatedUrlThrowsError()
 {
     $urlText = 'page-category-test-meta-url';
     $this->setExpectedException('LogicException', 'Given URL already exists');
     // Create Page Category 1
     $category1 = new Category();
     $category1->setLocale('en');
     $category1->setTitle('...');
     $category1->setDescription('...');
     $category1->setStatus(true);
     $category1->setMetaUrl($urlText);
     $this->dm->persist($category1);
     $this->dm->flush();
     $this->dm->clear();
     // Create Page Category 2
     $category2 = new Category();
     $category2->setLocale('en');
     $category2->setTitle('...');
     $category2->setDescription('...');
     $category2->setStatus(true);
     $category2->setMetaUrl($urlText);
     $this->dm->persist($category2);
     $this->dm->flush();
     // Delete Page Category 1
     $category1 = $this->dm->getRepository('Aisel\\PageBundle\\Document\\Category')->findOneBy(['metaUrl' => $urlText]);
     $this->dm->remove($category1);
     $this->dm->flush();
     $this->dm->clear();
 }
 public function createNode($name)
 {
     $node = new Category();
     $node->setLocale('en');
     $node->setDescription('');
     $node->setMetaUrl('/' . md5(rand(111111, 999999)));
     $node->setTitle($name);
     $this->dm->persist($node);
     $this->dm->flush();
     return $node;
 }