public function testDuplicatedUrlThrowsError()
 {
     $urlText = 'product-category-test-meta-url';
     $this->setExpectedException('LogicException', 'Given URL already exists');
     // Create Product 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();
     // Create Product 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 Product Category 1
     $category1 = $this->dm->getRepository('Aisel\\ProductBundle\\Document\\Category')->findOneBy(['metaUrl' => $urlText]);
     $this->dm->remove($category1);
     $this->dm->flush();
 }
 public function createNode($name)
 {
     $node = new Category();
     $node->setLocale('en');
     $node->setDescription('');
     $node->setMetaUrl('/' . rand(111111, 999999));
     $node->setTitle($name);
     $this->dm->persist($node);
     $this->dm->flush();
     return $node;
 }
 /**
  * {@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) {
                 $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 ($table->column[2] != 'NULL') {
                     $parent = $this->getReference('product_category_' . $table->column[2]);
                     $category->setParent($parent);
                 }
                 $manager->persist($category);
                 $manager->flush();
                 $this->addReference('product_category_' . $table->column[0], $category);
             }
         }
     }
 }