public function testDuplicatedUrlThrowsError() { $urlText = 'product-node-test-meta-url'; $this->setExpectedException('LogicException', 'Given URL already exists'); // Create Product 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(); // Create Product 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 Product Node 1 $node1 = $this->dm->getRepository('Aisel\\ProductBundle\\Document\\Node')->findOneBy(['metaUrl' => $urlText]); $this->dm->remove($node1); $this->dm->flush(); }
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()); $product = new Product(); $product->setLocale('en'); $product->setName($this->faker->sentence(1)); $product->setDescriptionShort($this->faker->sentence(10)); $product->setDescription($this->faker->sentence(10)); $product->setStatus(true); $product->setCommentStatus(true); $product->setMetaUrl('url_' . time()); $product->addNode($node); $product->addNode($node); $this->dm->persist($product); $this->dm->flush(); $this->assertNotNull($product->getId()); $this->assertEquals(count($product->getNodes()), 1); $this->dm->remove($node); $this->dm->flush(); $this->dm->remove($product); $this->dm->flush(); }
public function createNode($name) { $node = new Node(); $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) { $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 ($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); } } } }