Beispiel #1
0
 public function testDuplicateNodes()
 {
     $this->setExpectedException('Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException');
     $user = $this->em->getRepository('Aisel\\UserBundle\\Entity\\User')->findOneBy(['email' => '*****@*****.**']);
     $node = new Node();
     $node->setStatus(true);
     $node->setName($this->faker->sentence(1));
     $node->setContent($this->faker->sentence(10));
     $node->setMetaUrl('url_' . time());
     $node->setLocale('en');
     $this->em->persist($node);
     $this->em->flush();
     $this->assertNotNull($node->getId());
     $product = new Product();
     $product->setUser($user);
     $product->setLocale('en');
     $product->setSku($this->faker->numberBetween());
     $product->setName($this->faker->sentence(1));
     $product->setContentShort($this->faker->sentence(10));
     $product->setContent($this->faker->sentence(10));
     $product->setStatus(true);
     $product->setCommentStatus(true);
     $product->setMetaUrl('url_' . time());
     $product->addNode($node);
     $product->addNode($node);
     $this->em->persist($product);
     $this->em->flush();
 }
 public function testDuplicatedUrlThrowsError()
 {
     $urlText = 'product-node-test-meta-url';
     $this->setExpectedException('LogicException', 'Given URL already exists');
     $user = $this->em->getRepository('Aisel\\UserBundle\\Entity\\User')->findOneBy(['username' => 'user']);
     // Create Product 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();
     // Create Product 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 Product Node 1
     $node1 = $this->em->getRepository('Aisel\\ProductBundle\\Entity\\Node')->findOneBy(['metaUrl' => $urlText]);
     $this->em->remove($node1);
     $this->em->flush();
 }
Beispiel #3
0
 public function testDuplicateNodes()
 {
     $this->setExpectedException('Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException');
     $node = new Node();
     $node->setStatus(true);
     $node->setName($this->faker->sentence(1));
     $node->setContent($this->faker->sentence(10));
     $node->setMetaUrl('url_' . time());
     $node->setLocale('en');
     $this->em->persist($node);
     $this->em->flush();
     $this->assertNotNull($node->getId());
     $product = new Product();
     $product->setLocale('en');
     $product->setSku($this->faker->numberBetween());
     $product->setName($this->faker->sentence(1));
     $product->setContentShort($this->faker->sentence(10));
     $product->setContent($this->faker->sentence(10));
     $product->setStatus(true);
     $product->setCommentStatus(true);
     $product->setMetaUrl('url_' . time());
     $product->addNode($node);
     $product->addNode($node);
     $this->em->persist($product);
     $this->em->flush();
 }
Beispiel #4
0
 /**
  * newNode
  *
  * @return Node $node
  */
 public function newNode()
 {
     $node = new Node();
     $node->setName($this->faker->sentence());
     $node->setStatus(true);
     $node->setContent($this->faker->sentence());
     $node->setLocale('en');
     $node->setMetaUrl($this->faker->sentence());
     $this->em->persist($node);
     $this->em->flush();
     return $node;
 }
Beispiel #5
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) {
                 $node = new Node();
                 $node->setLocale($table->column[1]);
                 $node->setName($table->column[3]);
                 $node->setContent($table->column[8]);
                 $node->setStatus((int) $table->column[9]);
                 $node->setMetaUrl($table->column[10]);
                 if ($table->column[2] != 'NULL') {
                     $parent = $this->getReference('product_node_' . $table->column[2]);
                     $node->setParent($parent);
                 }
                 $manager->persist($node);
                 $manager->flush();
                 $this->addReference('product_node_' . $table->column[0], $node);
             }
         }
     }
 }